[llvm] [SCEV] Simplify `udiv` equality comparisons against 0 (PR #218084)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 27 08:50:57 PDT 2026


================
@@ -11113,6 +11113,17 @@ bool ScalarEvolution::SimplifyICmpOperands(CmpPredicate &Pred, SCEVUse &LHS,
     }
   }
 
+  // For a defined unsigned division, the quotient is zero exactly when the
+  // numerator is less than the denominator. The constant-range canonicalization
+  // above reduces equivalent zero/nonzero comparisons to EQ/NE against zero.
+  if (const auto *Div = dyn_cast<SCEVUDivExpr>(LHS);
+      Div && RHS->isZero() && ICmpInst::isEquality(Pred)) {
----------------
fhahn wrote:

this may be clearer using `m_scev_UDiv`?

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


More information about the llvm-commits mailing list