[PATCH] D106580: [LoopFlatten] Use SCEV and Loop APIs to identify increment and trip count

Rosie Sumpter via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 26 09:23:19 PDT 2021


RosieSumpter added inline comments.


================
Comment at: llvm/lib/Transforms/Scalar/LoopFlatten.cpp:109
 
+  // Loop induction variable must start at zero and increment with a step size
+  // of one.
----------------
fhahn wrote:
> This is just a limitation to keep the implementation simpler at the moment right? Might be worth clarifying in the comment.
Ok sure, there is also a note mentioning this in lines 77/78. I will add some clarification that this is to simplify the implementation before committing.


================
Comment at: llvm/lib/Transforms/Scalar/LoopFlatten.cpp:160
+  // increment variable.
+  Increment =
+      dyn_cast<BinaryOperator>(InductionPHI->getIncomingValueForBlock(Latch));
----------------
fhahn wrote:
> Is later code somewhere relying that the increment is an add instruction? What if it is something like an extend?
No, we don't rely on it being an Add instruction. Using SCEV, it is now guaranteed that the loop starts at 0 and increments with 1. Most of the pattern matching that we replaced was to ensure that. The increment is also marked as an "IterationInstruction", but that's only for cost-modeling purposes and it doesn't rely on Adds.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106580/new/

https://reviews.llvm.org/D106580



More information about the llvm-commits mailing list