@@ -538,29 +538,28 @@ static bool processAbsIntrinsic(IntrinsicInst *II, LazyValueInfo *LVI) {
538
538
return false ;
539
539
}
540
540
541
- static bool processCmpIntrinsic (IntrinsicInst *II, LazyValueInfo *LVI) {
542
- bool IsSigned = II->getIntrinsicID () == Intrinsic::scmp;
543
- ConstantRange LHS_CR = LVI->getConstantRangeAtUse (II->getOperandUse (0 ),
544
- /* UndefAllowed*/ false );
545
- ConstantRange RHS_CR = LVI->getConstantRangeAtUse (II->getOperandUse (1 ),
546
- /* UndefAllowed*/ false );
541
+ static bool processCmpIntrinsic (CmpIntrinsic *CI, LazyValueInfo *LVI) {
542
+ ConstantRange LHS_CR =
543
+ LVI->getConstantRangeAtUse (CI->getOperandUse (0 ), /* UndefAllowed*/ false );
544
+ ConstantRange RHS_CR =
545
+ LVI->getConstantRangeAtUse (CI->getOperandUse (1 ), /* UndefAllowed*/ false );
547
546
548
- if (LHS_CR.icmp (IsSigned ? ICmpInst::ICMP_SGT : ICmpInst::ICMP_UGT , RHS_CR)) {
547
+ if (LHS_CR.icmp (CI-> getGTPredicate () , RHS_CR)) {
549
548
++NumCmpIntr;
550
- II ->replaceAllUsesWith (ConstantInt::get (II ->getType (), 1 ));
551
- II ->eraseFromParent ();
549
+ CI ->replaceAllUsesWith (ConstantInt::get (CI ->getType (), 1 ));
550
+ CI ->eraseFromParent ();
552
551
return true ;
553
552
}
554
- if (LHS_CR.icmp (IsSigned ? ICmpInst::ICMP_SLT : ICmpInst::ICMP_ULT , RHS_CR)) {
553
+ if (LHS_CR.icmp (CI-> getLTPredicate () , RHS_CR)) {
555
554
++NumCmpIntr;
556
- II ->replaceAllUsesWith (ConstantInt::getSigned (II ->getType (), -1 ));
557
- II ->eraseFromParent ();
555
+ CI ->replaceAllUsesWith (ConstantInt::getSigned (CI ->getType (), -1 ));
556
+ CI ->eraseFromParent ();
558
557
return true ;
559
558
}
560
559
if (LHS_CR.icmp (ICmpInst::ICMP_EQ, RHS_CR)) {
561
560
++NumCmpIntr;
562
- II ->replaceAllUsesWith (ConstantInt::get (II ->getType (), 0 ));
563
- II ->eraseFromParent ();
561
+ CI ->replaceAllUsesWith (ConstantInt::get (CI ->getType (), 0 ));
562
+ CI ->eraseFromParent ();
564
563
return true ;
565
564
}
566
565
@@ -658,9 +657,8 @@ static bool processCallSite(CallBase &CB, LazyValueInfo *LVI) {
658
657
return processAbsIntrinsic (&cast<IntrinsicInst>(CB), LVI);
659
658
}
660
659
661
- if (CB.getIntrinsicID () == Intrinsic::scmp ||
662
- CB.getIntrinsicID () == Intrinsic::ucmp) {
663
- return processCmpIntrinsic (&cast<IntrinsicInst>(CB), LVI);
660
+ if (auto *CI = dyn_cast<CmpIntrinsic>(&CB)) {
661
+ return processCmpIntrinsic (CI, LVI);
664
662
}
665
663
666
664
if (auto *MM = dyn_cast<MinMaxIntrinsic>(&CB)) {
0 commit comments