[llvm] [LV] Skip sentinel value for FindLastIV reductions when start value is provably less than IV start. (PR #141788)

Ramkumar Ramachandra via llvm-commits llvm-commits at lists.llvm.org
Thu May 29 01:18:38 PDT 2025


================
@@ -730,17 +737,32 @@ RecurrenceDescriptor::isFindLastIVPattern(Loop *TheLoop, PHINode *OrigPhi,
                       << IVRange << "\n");
     // Ensure the induction variable does not wrap around by verifying that its
     // range is fully contained within the valid range.
-    return ValidRange.contains(IVRange);
+    if (!ValidRange.contains(IVRange))
+      return {false, nullptr};
+
+    // No sentinel is needed if it can be proven that the start value of
+    // reduction is strictly less than the start value of increasing induction
+    // variable.
+    if (auto *ConstIVStart = dyn_cast<SCEVConstant>(AR->getStart())) {
----------------
artagnon wrote:

m_scev_APInt()?

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


More information about the llvm-commits mailing list