@@ -2981,7 +2981,7 @@ static Value *simplifyICmpWithZero(CmpPredicate Pred, Value *LHS, Value *RHS,
29812981}
29822982
29832983static Value *simplifyICmpWithConstant (CmpPredicate Pred, Value *LHS,
2984- Value *RHS, const InstrInfoQuery &IIQ ) {
2984+ Value *RHS, const SimplifyQuery &Q ) {
29852985 Type *ITy = getCompareTy (RHS); // The return type.
29862986
29872987 Value *X;
@@ -3007,7 +3007,7 @@ static Value *simplifyICmpWithConstant(CmpPredicate Pred, Value *LHS,
30073007 return ConstantInt::getTrue (ITy);
30083008
30093009 ConstantRange LHS_CR =
3010- computeConstantRange (LHS, CmpInst::isSigned (Pred), IIQ.UseInstrInfo );
3010+ computeConstantRange (LHS, CmpInst::isSigned (Pred), Q. IIQ .UseInstrInfo );
30113011 if (!LHS_CR.isFullSet ()) {
30123012 if (RHS_CR.contains (LHS_CR))
30133013 return ConstantInt::getTrue (ITy);
@@ -3018,13 +3018,16 @@ static Value *simplifyICmpWithConstant(CmpPredicate Pred, Value *LHS,
30183018 // (mul nuw/nsw X, MulC) != C --> true (if C is not a multiple of MulC)
30193019 // (mul nuw/nsw X, MulC) == C --> false (if C is not a multiple of MulC)
30203020 const APInt *MulC;
3021- if (IIQ.UseInstrInfo && ICmpInst::isEquality (Pred) &&
3021+ if (Q. IIQ .UseInstrInfo && ICmpInst::isEquality (Pred) &&
30223022 ((match (LHS, m_NUWMul (m_Value (), m_APIntAllowPoison (MulC))) &&
30233023 *MulC != 0 && C->urem (*MulC) != 0 ) ||
30243024 (match (LHS, m_NSWMul (m_Value (), m_APIntAllowPoison (MulC))) &&
30253025 *MulC != 0 && C->srem (*MulC) != 0 )))
30263026 return ConstantInt::get (ITy, Pred == ICmpInst::ICMP_NE);
30273027
3028+ if (ICmpInst::isGE (Pred) && C->isOne () && isKnownNonZero (LHS, Q))
3029+ return ConstantInt::getTrue (ITy);
3030+
30283031 return nullptr ;
30293032}
30303033
@@ -3776,7 +3779,7 @@ static Value *simplifyICmpInst(CmpPredicate Pred, Value *LHS, Value *RHS,
37763779 if (Value *V = simplifyICmpWithZero (Pred, LHS, RHS, Q))
37773780 return V;
37783781
3779- if (Value *V = simplifyICmpWithConstant (Pred, LHS, RHS, Q. IIQ ))
3782+ if (Value *V = simplifyICmpWithConstant (Pred, LHS, RHS, Q))
37803783 return V;
37813784
37823785 // If both operands have range metadata, use the metadata
0 commit comments