[llvm] [InstSimplify] Canonicalize predicates into strict versions in `simplifyICmpInst` (PR #151642)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 7 07:40:23 PDT 2025
================
@@ -3774,6 +3771,17 @@ static Value *simplifyICmpInst(CmpPredicate Pred, Value *LHS, Value *RHS,
if (Value *V = simplifyICmpOfBools(Pred, LHS, RHS, Q))
return V;
+ const APInt *C;
+ if (match(RHS, m_APIntAllowPoison(C))) {
+ if (Pred == ICmpInst::ICMP_UGE && C->isOne()) {
+ Pred = ICmpInst::ICMP_NE;
+ RHS = ConstantInt::get(RHS->getType(), 0);
+ } else if (Pred == ICmpInst::ICMP_SLE && C->isAllOnes()) {
+ Pred = ICmpInst::ICMP_SLT;
+ RHS = ConstantInt::get(RHS->getType(), 0);
+ }
+ }
----------------
nikic wrote:
What regressions do you see without the !isZero() check?
https://github.com/llvm/llvm-project/pull/151642
More information about the llvm-commits
mailing list