[llvm-branch-commits] [llvm] [LoopInterchange] Reject if inner loop IV has outer-variant step (PR #202751)

Ryotaro Kasuga via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Jun 9 12:52:56 PDT 2026


================
@@ -1370,11 +1373,17 @@ bool LoopInterchangeLegality::currentLimitations() {
 }
 
 bool LoopInterchangeLegality::findInductions(
-    Loop *L, SmallVectorImpl<PHINode *> &Inductions) {
-  for (PHINode &PHI : L->getHeader()->phis()) {
+    Loop *OuterLoop, Loop *InnerLoop, SmallVectorImpl<PHINode *> &Inductions) {
+  for (PHINode &PHI : InnerLoop->getHeader()->phis()) {
     InductionDescriptor ID;
-    if (InductionDescriptor::isInductionPHI(&PHI, L, SE, ID))
-      Inductions.push_back(&PHI);
+    if (!InductionDescriptor::isInductionPHI(&PHI, InnerLoop, SE, ID))
+      continue;
----------------
kasuga-fj wrote:

TBH, I'm not entirely sure what happens when there's a PHI in the inner loop that isn't an induction variable. I think I need to dig deeper into such cases...

https://github.com/llvm/llvm-project/pull/202751


More information about the llvm-branch-commits mailing list