[llvm] [LAA] Prove monotonicity of add/mul expressions. (PR #220715)

Michael Kruse via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 17 05:51:00 PDT 2026


================
@@ -346,6 +346,17 @@ static bool isKnownNonDecreasingInLoop(const SCEV *S, const Loop *L,
     return SE.getMonotonicPredicateType(AR, ICmpInst::ICMP_UGE) ==
            ScalarEvolution::MonotonicPredicateType::MonotonicallyIncreasing;
   }
+  case scAddExpr:
+  case scMulExpr: {
+    const auto *NAry = cast<SCEVNAryExpr>(S);
+    if (!NAry->hasNoUnsignedWrap())
+      return false;
+    // With NUW, the exact sum or product fits in the type, so it is
+    // non-decreasing if every operandis.
----------------
Meinersbur wrote:

```suggestion
    // non-decreasing if every operand is.
```

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


More information about the llvm-commits mailing list