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

Sjoerd Meijer via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 23 01:38:59 PDT 2021


SjoerdMeijer added inline comments.


================
Comment at: llvm/lib/Transforms/Scalar/LoopFlatten.cpp:125
 
+  assert(InductionPHI->getNumIncomingValues() == 2);
+  
----------------
I am not sure if an induction phi can have > 2 incoming values. If it can then the assert needs to be a return, and a test case is missing for this.

But if `getNumIncomingValues() == 2` is guaranteed by `getInductionVariable()`, then this is fine. Can you double check by looking at `getInductionVariable()`?


================
Comment at: llvm/lib/Transforms/Scalar/LoopFlatten.cpp:156
 
-  // Find increment and limit from the compare
+  // Find increment and limit.
+  // The loop must be canonical, and there are exactly 2 incoming values to the
----------------
Just for clarity, I was wondering if we should rename limit to trip count, because that is what it is at the moment with the restriction that our loops start counting at 0. I think that makes things clearer now that we start using SCEV and request trip counts.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106580



More information about the llvm-commits mailing list