[PATCH] D16550: Reroll loops with multiple IV and negative step part 3/3 -- support multiple induction variables

Lawrence Hu via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 30 15:10:38 PDT 2016


hulx2000 marked 12 inline comments as done.

================
Comment at: lib/Transforms/Scalar/LoopRerollPass.cpp:528
@@ +527,3 @@
+//    used by PHI, compare is only used by branch.
+bool LoopReroll::isLoopCtrlOnlyIV(Loop *L, Instruction *IV) {
+
----------------
jmolloy wrote:
> Can't you just use InductionInfo::isInduction() here? You'd be looking for an induction with a step of 1 that is used by the loop latch. It seems this could remove a lot of code.
Here I am checking if an induction PHI is only used to control loop iteration, no other uses such as A[i], normally, an Induction PHI will have other uses other than controlling loop iteration, e.g.   Used as an index to access array.

So InductionDescriptor::isInductionPHI is not enough here. 

================
Comment at: lib/Transforms/Scalar/LoopRerollPass.cpp:1170
@@ +1169,3 @@
+  BasicBlock *Header = L->getHeader();
+  if (LoopCtrlOnlyIV && LoopCtrlOnlyIV != IV) {
+    for (auto *U : LoopCtrlOnlyIV->users()) {
----------------
jmolloy wrote:
> This is really nasty. Please come up with a more concise way of expressing this.
> 
> (If you used InductionDescriptor to represent LoopControlIV, this should be fairly easy I think?)
Here I am trying to mark the Loop Control Only IV and it's related instructions such as increment, compare and branches as used, InductionDescriptor can't help much here.

And there seems no other way around it without adding more code, may be I could add more comments instead?


Repository:
  rL LLVM

http://reviews.llvm.org/D16550





More information about the llvm-commits mailing list