@@ -2528,30 +2528,6 @@ Instruction *InstCombinerImpl::foldICmpShrConstant(ICmpInst &Cmp,
2528
2528
Instruction *InstCombinerImpl::foldICmpSRemConstant (ICmpInst &Cmp,
2529
2529
BinaryOperator *SRem,
2530
2530
const APInt &C) {
2531
- {
2532
- const APInt *C1;
2533
- ICmpInst::Predicate Pred = Cmp.getPredicate ();
2534
- if ((match (SRem->getOperand (1 ), m_NonNegative (C1))) &&
2535
- ((Pred == ICmpInst::ICMP_SLT && C == *C1 - 1 ) ||
2536
- (Pred == ICmpInst::ICMP_SGT && C == *C1 - 2 ) ||
2537
- (Pred == ICmpInst::ICMP_SGT && C == -*C1 + 1 ) ||
2538
- (Pred == ICmpInst::ICMP_SLT && C == -*C1 + 2 ))) {
2539
- // icmp slt (X s% C), (C - 1) --> icmp ne (X s% C), (C - 1), if C >= 0
2540
- // icmp sgt (X s% C), (C - 2) --> icmp eq (X s% C), (C - 1), if C >= 0
2541
- // icmp sgt (X s% C), (-C + 1) --> icmp ne (X s% C), (-C + 1), if C >= 0
2542
- // icmp slt (X s% C), (-C + 2) --> icmp eq (X s% C), (-C + 1), if C >= 0
2543
- return new ICmpInst (
2544
- ((Pred == ICmpInst::ICMP_SLT && C == *C1 - 1 ) ||
2545
- (Pred == ICmpInst::ICMP_SGT && C == -*C1 + 1 ))
2546
- ? ICmpInst::ICMP_NE
2547
- : ICmpInst::ICMP_EQ,
2548
- SRem,
2549
- ConstantInt::get (SRem->getType (), C == -*C1 + 1 || C == -*C1 + 2
2550
- ? -*C1 + 1
2551
- : *C1 - 1 ));
2552
- }
2553
- }
2554
-
2555
2531
// Match an 'is positive' or 'is negative' comparison of remainder by a
2556
2532
// constant power-of-2 value:
2557
2533
// (X % pow2C) sgt/slt 0
@@ -2599,23 +2575,6 @@ Instruction *InstCombinerImpl::foldICmpSRemConstant(ICmpInst &Cmp,
2599
2575
return new ICmpInst (ICmpInst::ICMP_UGT, And, ConstantInt::get (Ty, SignMask));
2600
2576
}
2601
2577
2602
- Instruction *InstCombinerImpl::foldICmpURemConstant (ICmpInst &Cmp,
2603
- BinaryOperator *URem,
2604
- const APInt &C) {
2605
- const APInt *C1;
2606
- ICmpInst::Predicate Pred = Cmp.getPredicate ();
2607
- if (match (URem->getOperand (1 ), m_APInt (C1)) &&
2608
- ((Pred == ICmpInst::ICMP_ULT && C == *C1 - 1 ) ||
2609
- (Pred == ICmpInst::ICMP_UGT && C == *C1 - 2 && C.ugt (1 )))) {
2610
- // icmp ult (X u% C), (C - 1) --> icmp ne (X u% C), (C - 1)
2611
- // icmp ugt (X u% C), (C - 2) --> icmp eq (X u% C), (C - 1), if C >u 1
2612
- return new ICmpInst (Pred == ICmpInst::ICMP_UGT ? ICmpInst::ICMP_EQ
2613
- : ICmpInst::ICMP_NE,
2614
- URem, ConstantInt::get (URem->getType (), *C1 - 1 ));
2615
- }
2616
- return nullptr ;
2617
- }
2618
-
2619
2578
// / Fold icmp (udiv X, Y), C.
2620
2579
Instruction *InstCombinerImpl::foldICmpUDivConstant (ICmpInst &Cmp,
2621
2580
BinaryOperator *UDiv,
@@ -3753,10 +3712,6 @@ Instruction *InstCombinerImpl::foldICmpBinOpWithConstant(ICmpInst &Cmp,
3753
3712
if (Instruction *I = foldICmpSRemConstant (Cmp, BO, C))
3754
3713
return I;
3755
3714
break ;
3756
- case Instruction::URem:
3757
- if (Instruction *I = foldICmpURemConstant (Cmp, BO, C))
3758
- return I;
3759
- break ;
3760
3715
case Instruction::UDiv:
3761
3716
if (Instruction *I = foldICmpUDivConstant (Cmp, BO, C))
3762
3717
return I;
0 commit comments