[llvm] [SCEV] Use equiv of X >= Y and X > Y - 1 to sharpen implication (PR #222939)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 11 11:15:39 PDT 2026


================
@@ -12350,11 +12350,17 @@ bool ScalarEvolution::isImpliedCondBalancedTypes(
       if (isImpliedCondOperands(FoundPred, LHS, RHS, FoundLHS, FoundRHS, CtxI))
         return true;
 
-  if (isImpliedCondOperandsViaRanges(Pred, LHS, RHS, FoundPred, FoundLHS, FoundRHS))
+  // X >= Y is equivalent to X > Y - 1, 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.
----------------
nikic wrote:

For Y == 0, we have X >= 0 is true, but X > MAX is false. Am I missing something?

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


More information about the llvm-commits mailing list