[PATCH] D13974: [IndVarSimplify] Rewrite loop exit values with their initial values from loop preheader

Chen Li via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 22 11:16:41 PDT 2015


chenli added inline comments.

================
Comment at: lib/Transforms/Scalar/IndVarSimplify.cpp:758
@@ +757,3 @@
+      // incoming block as loop preheader, and others as back edges.
+      auto *InductionPHI =
+          dyn_cast<PHINode>(PN->getIncomingValue(0));
----------------
sanjoy wrote:
> chenli wrote:
> > sanjoy wrote:
> > > How do you know that the 0th incoming value to `PN` is an induction PHI node?
> > This is basically because of the previous assumption that we only have single entry PHI here. So if there is an induction PHI node, it should be 0th. The later 
> > ```
> > InductionPHI->getBasicBlockIndex(LoopPreheader) != -1
> > ```
> > is used to filter non-induction PHI node. 
> > The name InductionPHI is confusing because it's not necessary an indication PHI if it fails the check. 
> > I will refactor the code to make it cleaner.
> In any case, we don't really care about the PHI being an induction variable (i.e. a integer that increases / decreases by some amount every iteration) -- whatever the value incoming from the preheader -> header edge is will be the exit value of the PHI.  So perhaps it makes sense to not call the value `InductionPHI`?
Yes, I will definitely pick a better name :)


http://reviews.llvm.org/D13974





More information about the llvm-commits mailing list