[llvm] [IVDescriptors] Implement MonotonicDescriptor (PR #214490)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Sat Sep 12 02:03:37 PDT 2026
================
@@ -1696,3 +1696,94 @@ bool InductionDescriptor::isInductionPHI(
/*InductionBinOp=*/nullptr, /*Casts=*/nullptr, Preds);
return true;
}
+
+// Recognize a monotonic PHI variable by matching the following pattern:
+// loop_header:
+// %monotonic_phi = phi [ %start, %preheader ], [ %latch_phi, %latch ]
+// br i1 %do_step, label %step_bb, label %latch
+//
+// step_bb:
+// %step = add/gep %monotonic_phi, %step_val
+// br label %latch
+//
+// latch:
+// %latch_phi = phi [ %monotonic_phi, %loop_header ], [ %step, %step_bb ]
+// br label %loop_header
+bool MonotonicDescriptor::isMonotonicPHI(PHINode *HeaderPHI, const Loop *L,
----------------
fhahn wrote:
```suggestion
bool MonotonicDescriptor::isMonotonicPHI(PHINode *PN, const Loop *L,
```
for consistency with declaration
https://github.com/llvm/llvm-project/pull/214490
More information about the llvm-commits
mailing list