[PATCH] D20174: [InstCombine] Allow removal of PHI cycles which only contain PHIs

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Wed May 11 17:25:10 PDT 2016


reames added a subscriber: reames.

================
Comment at: lib/Transforms/InstCombine/InstCombinePHI.cpp:972
@@ +971,3 @@
+      InValNo = 0;
+      while (InValNo != NumIncomingVals) {
+        Value *Val = PN.getIncomingValue(InValNo);
----------------
Repeating this for each incoming value seems likely to be expensive.  Can we do better?  As one filter, we know that for the phi to be equal to some value, that value must dominate the phi or be a non-instruction value right?  If so, can we use that?  

Another option on how to approach this would be an inductive proof over the loop.  On iteration 1, we know that %p2 = %p0 and thus that on every future iteration all inputes to the phis equal %p0.  Framing this using a loop pass (possibly indvarsimplify?) might be another approach.  

To be clear, I'm okay with the patch in it's current form if we can't find a better approach.  I'm just asking to make sure we've explored all the options before eating the compile time.


http://reviews.llvm.org/D20174





More information about the llvm-commits mailing list