[llvm] [IVDescriptors] Implement MonotonicDescriptor (PR #214490)
Luke Lau via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 28 03:20:49 PDT 2026
================
@@ -1696,3 +1696,95 @@ 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
----------------
lukel97 wrote:
Is it safe to consider a phi that can wrap as monotonic? Looking at the test cases in #214491 the steps all have the `nsw` flag, I'm guessing it's not safe to consider a pointer as a compressing pointer without it?
If so, do we need to check for that in this PR and return false for `isMonotonicPHI`, or do we handle it in #214491 by checking `SCEVNoWrapFlags`?
https://github.com/llvm/llvm-project/pull/214490
More information about the llvm-commits
mailing list