[PATCH] D88979: [InstCombine] combineLoadToOperationType(): don't fold int<->ptr cast into load

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 7 09:53:13 PDT 2020


lebedev.ri created this revision.
lebedev.ri added reviewers: efriedma, nlopes, spatel, nikic.
lebedev.ri added a project: LLVM.
Herald added a subscriber: hiraditya.
lebedev.ri requested review of this revision.

And another step towards transforms not introducing inttoptr and/or
ptrtoint casts that weren't there already.

As we've been establishing (see D88788 <https://reviews.llvm.org/D88788>/D88789 <https://reviews.llvm.org/D88789>), if there is a int<->ptr cast,
it basically must stay as-is, we can't do much with it.

I've looked, and the most source of new such casts being introduces,
as far as i can tell, is this transform, which, ironically,
tries to reduce count of casts..

On vanilla llvm test-suite + RawSpeed, @ `-O3`, this results in
-33.58% less `IntToPtr`s and +76.20% more `PtrToInt`s; however just on RawSpeed,
where i know there are basically none `IntToPtr` in the original source code,
this results in -99.27% less `IntToPtr`s (2724 - 2704 -> 20)
and +82.92% more `PtrToInt`s.

So it does seem like the step in the right direction.
I'm not presently sure what preparatory fixes are needed before this though.

(Eventually, `CastInst::isNoopCast()`/`CastInst::isEliminableCastPair`
should be taught about this, yes)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D88979

Files:
  llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
  llvm/test/Transforms/InstCombine/PR30597.ll
  llvm/test/Transforms/InstCombine/intptr1.ll
  llvm/test/Transforms/InstCombine/load-bitcast32.ll
  llvm/test/Transforms/InstCombine/load-bitcast64.ll
  llvm/test/Transforms/InstCombine/memset_chk-1.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D88979.296715.patch
Type: text/x-patch
Size: 13585 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201007/838b8823/attachment.bin>


More information about the llvm-commits mailing list