Skip to content

Commit f858afb

Browse files
committed
invert non-strict predicates
1 parent a3aa738 commit f858afb

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

llvm/lib/Analysis/InstructionSimplify.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3772,13 +3772,12 @@ static Value *simplifyICmpInst(CmpPredicate Pred, Value *LHS, Value *RHS,
37723772
return V;
37733773

37743774
const APInt *C;
3775-
if (match(RHS, m_APIntAllowPoison(C))) {
3776-
if (Pred == ICmpInst::ICMP_UGE && C->isOne()) {
3777-
Pred = ICmpInst::ICMP_NE;
3778-
RHS = ConstantInt::get(RHS->getType(), 0);
3779-
} else if (Pred == ICmpInst::ICMP_SLE && C->isAllOnes()) {
3780-
Pred = ICmpInst::ICMP_SLT;
3781-
RHS = ConstantInt::get(RHS->getType(), 0);
3775+
if (match(RHS, m_APIntAllowPoison(C)) &&
3776+
ICmpInst::isNonStrictPredicate(Pred) && !C->isZero()) {
3777+
if (auto Flipped = getFlippedStrictnessPredicateAndConstant(
3778+
Pred, ConstantInt::get(LHS->getType(), *C))) {
3779+
Pred = Flipped->first;
3780+
RHS = Flipped->second;
37823781
}
37833782
}
37843783

0 commit comments

Comments
 (0)