[llvm] [InstSimplify] Simplify 'x u>= 1' to true when x is known non-zero (PR #145204)
Iris Shi via llvm-commits
llvm-commits at lists.llvm.org
Sun Jun 22 02:42:37 PDT 2025
================
@@ -3018,13 +3018,16 @@ static Value *simplifyICmpWithConstant(CmpPredicate Pred, Value *LHS,
// (mul nuw/nsw X, MulC) != C --> true (if C is not a multiple of MulC)
// (mul nuw/nsw X, MulC) == C --> false (if C is not a multiple of MulC)
const APInt *MulC;
- if (IIQ.UseInstrInfo && ICmpInst::isEquality(Pred) &&
+ if (Q.IIQ.UseInstrInfo && ICmpInst::isEquality(Pred) &&
((match(LHS, m_NUWMul(m_Value(), m_APIntAllowPoison(MulC))) &&
*MulC != 0 && C->urem(*MulC) != 0) ||
(match(LHS, m_NSWMul(m_Value(), m_APIntAllowPoison(MulC))) &&
*MulC != 0 && C->srem(*MulC) != 0)))
return ConstantInt::get(ITy, Pred == ICmpInst::ICMP_NE);
+ if (Pred == ICmpInst::ICMP_UGE && C->isOne() && isKnownNonZero(LHS, Q))
+ return ConstantInt::getTrue(ITy);
----------------
el-ev wrote:
I agree that this looks more like a workaround. However, we can keep this until a real solution is landed, at which point we can simply revert this.
https://github.com/llvm/llvm-project/pull/145204
More information about the llvm-commits
mailing list