[PATCH] D98058: [InstCombine] Simplify phis with incoming pointer-casts.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 5 10:04:30 PST 2021


fhahn created this revision.
fhahn added reviewers: lebedev.ri, spatel, RKSimon, dmgreen.
Herald added subscribers: pengfei, hiraditya.
fhahn requested review of this revision.
Herald added a project: LLVM.

If the incoming values of a phi are pointer casts of the same original
value, replace the phi with a single cast. Such redundant phis are
somewhat common after loop-rotate and removing them can avoid some
unnecessary code bloat, e.g. because an iteration of a loop is peeled
off to make the phi invariant. It should also simplify further analysis
on its own.

InstCombine already uses stripPointerCasts in a couple of places and
also simplifies phis based on the incoming values, so the patch should
fit in the existing scope.

The patch causes binary changes in 47 out of 237 benchmarks in
MultiSource/SPEC2000/SPEC2006 with -O3 -flto on X86.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98058

Files:
  llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp
  llvm/test/Transforms/InstCombine/phi-pointercasts.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D98058.328570.patch
Type: text/x-patch
Size: 4570 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210305/679fbd24/attachment.bin>


More information about the llvm-commits mailing list