[llvm] [SCEV] Use X > Y - 1 => X >= Y to sharpen implication (PR #222939)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 17 03:31:21 PDT 2026
================
@@ -12190,6 +12176,17 @@ bool ScalarEvolution::isImpliedCond(CmpPredicate Pred, const SCEV *LHS,
FoundRHS = getZeroExtendExpr(FoundRHS, LHS->getType());
}
}
+
+ // X > Y - 1 implies X >= Y, and this holds trivially when Y - 1 does not
+ // overflow. When it does overflow, it must be INT_MAX, and the comparison
+ // would evaluate to false anyway. Here, we transform precondition X > Y into
+ // X >= Y + 1.
+ if (ICmpInst::isGT(FoundPred) &&
----------------
nikic wrote:
Missing check that Pred == ICmpInst::getNonStrictCmpPredicate(FoundPred)? I think your code assumes this is the case.
https://github.com/llvm/llvm-project/pull/222939
More information about the llvm-commits
mailing list