@@ -6544,35 +6544,6 @@ bool InstCombinerImpl::replacedSelectWithOperand(SelectInst *SI,
6544
6544
return false ;
6545
6545
}
6546
6546
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
-
6576
6547
// / Try to fold the comparison based on range information we can get by checking
6577
6548
// / whether bits are known to be zero or one in the inputs.
6578
6549
Instruction *InstCombinerImpl::foldICmpUsingKnownBits (ICmpInst &I) {
@@ -6612,7 +6583,7 @@ Instruction *InstCombinerImpl::foldICmpUsingKnownBits(ICmpInst &I) {
6612
6583
return new ICmpInst (
6613
6584
Pred, Op0, ConstantExpr::getIntegerValue (Ty, Op1Known.getConstant ()));
6614
6585
6615
- if (std::optional<bool > Res = compareKnownBits (Pred, Op0Known, Op1Known))
6586
+ if (std::optional<bool > Res = ICmpInst::compare ( Op0Known, Op1Known, Pred ))
6616
6587
return replaceInstUsesWith (I, ConstantInt::getBool (I.getType (), *Res));
6617
6588
6618
6589
// Given the known and unknown bits, compute a range that the LHS could be
0 commit comments