[llvm] [ValueTracking] a u>= b and a = b + NonZero implies a != 0 (PR #219103)

via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 31 00:40:45 PDT 2026


================
@@ -10017,6 +10027,21 @@ llvm::isImpliedCondition(const Value *LHS, CmpPredicate RHSPred,
   if (match(LHS, m_Not(m_Value(LHS))))
     LHSIsTrue = !LHSIsTrue;
 
+  // umin(X, Y) with Y != 0 is zero iff X is zero, so for an equality against
+  // zero it is enough to look at X. Fall through with the original operands
+  // otherwise, e.g. when LHS is about the umin itself.
+  const Value *X, *Y;
+  if (ICmpInst::isEquality(RHSPred) && match(RHSOp1, m_Zero()) &&
+      match(RHSOp0, m_UMin(m_Value(X), m_Value(Y)))) {
+    SimplifyQuery SQ(DL);
+    if (isKnownNonZero(X, SQ))
+      std::swap(X, Y);
+    if (isKnownNonZero(Y, SQ))
----------------
ThePo1es wrote:

Reworked so that each operand is tested at most once (see the `DecidingOp` structure).

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


More information about the llvm-commits mailing list