Skip to content

Commit 136425b

Browse files
committed
use new helper
1 parent 82920a3 commit 136425b

File tree

1 file changed

+1
-30
lines changed

1 file changed

+1
-30
lines changed

llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6544,35 +6544,6 @@ bool InstCombinerImpl::replacedSelectWithOperand(SelectInst *SI,
65446544
return false;
65456545
}
65466546

6547-
static std::optional<bool> compareKnownBits(ICmpInst::Predicate Pred,
6548-
const KnownBits &Op0,
6549-
const KnownBits &Op1) {
6550-
switch (Pred) {
6551-
case ICmpInst::ICMP_EQ:
6552-
return KnownBits::eq(Op0, Op1);
6553-
case ICmpInst::ICMP_NE:
6554-
return KnownBits::ne(Op0, Op1);
6555-
case ICmpInst::ICMP_ULT:
6556-
return KnownBits::ult(Op0, Op1);
6557-
case ICmpInst::ICMP_ULE:
6558-
return KnownBits::ule(Op0, Op1);
6559-
case ICmpInst::ICMP_UGT:
6560-
return KnownBits::ugt(Op0, Op1);
6561-
case ICmpInst::ICMP_UGE:
6562-
return KnownBits::uge(Op0, Op1);
6563-
case ICmpInst::ICMP_SLT:
6564-
return KnownBits::slt(Op0, Op1);
6565-
case ICmpInst::ICMP_SLE:
6566-
return KnownBits::sle(Op0, Op1);
6567-
case ICmpInst::ICMP_SGT:
6568-
return KnownBits::sgt(Op0, Op1);
6569-
case ICmpInst::ICMP_SGE:
6570-
return KnownBits::sge(Op0, Op1);
6571-
default:
6572-
llvm_unreachable("Unknown predicate");
6573-
}
6574-
}
6575-
65766547
/// Try to fold the comparison based on range information we can get by checking
65776548
/// whether bits are known to be zero or one in the inputs.
65786549
Instruction *InstCombinerImpl::foldICmpUsingKnownBits(ICmpInst &I) {
@@ -6612,7 +6583,7 @@ Instruction *InstCombinerImpl::foldICmpUsingKnownBits(ICmpInst &I) {
66126583
return new ICmpInst(
66136584
Pred, Op0, ConstantExpr::getIntegerValue(Ty, Op1Known.getConstant()));
66146585

6615-
if (std::optional<bool> Res = compareKnownBits(Pred, Op0Known, Op1Known))
6586+
if (std::optional<bool> Res = ICmpInst::compare(Op0Known, Op1Known, Pred))
66166587
return replaceInstUsesWith(I, ConstantInt::getBool(I.getType(), *Res));
66176588

66186589
// Given the known and unknown bits, compute a range that the LHS could be

0 commit comments

Comments
 (0)