@@ -538,29 +538,28 @@ static bool processAbsIntrinsic(IntrinsicInst *II, LazyValueInfo *LVI) {
538538 return false ;
539539}
540540
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 );
547546
548- if (LHS_CR.icmp (IsSigned ? ICmpInst::ICMP_SGT : ICmpInst::ICMP_UGT , RHS_CR)) {
547+ if (LHS_CR.icmp (CI-> getGTPredicate () , RHS_CR)) {
549548 ++NumCmpIntr;
550- II ->replaceAllUsesWith (ConstantInt::get (II ->getType (), 1 ));
551- II ->eraseFromParent ();
549+ CI ->replaceAllUsesWith (ConstantInt::get (CI ->getType (), 1 ));
550+ CI ->eraseFromParent ();
552551 return true ;
553552 }
554- if (LHS_CR.icmp (IsSigned ? ICmpInst::ICMP_SLT : ICmpInst::ICMP_ULT , RHS_CR)) {
553+ if (LHS_CR.icmp (CI-> getLTPredicate () , RHS_CR)) {
555554 ++NumCmpIntr;
556- II ->replaceAllUsesWith (ConstantInt::getSigned (II ->getType (), -1 ));
557- II ->eraseFromParent ();
555+ CI ->replaceAllUsesWith (ConstantInt::getSigned (CI ->getType (), -1 ));
556+ CI ->eraseFromParent ();
558557 return true ;
559558 }
560559 if (LHS_CR.icmp (ICmpInst::ICMP_EQ, RHS_CR)) {
561560 ++NumCmpIntr;
562- II ->replaceAllUsesWith (ConstantInt::get (II ->getType (), 0 ));
563- II ->eraseFromParent ();
561+ CI ->replaceAllUsesWith (ConstantInt::get (CI ->getType (), 0 ));
562+ CI ->eraseFromParent ();
564563 return true ;
565564 }
566565
@@ -658,9 +657,8 @@ static bool processCallSite(CallBase &CB, LazyValueInfo *LVI) {
658657 return processAbsIntrinsic (&cast<IntrinsicInst>(CB), LVI);
659658 }
660659
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);
664662 }
665663
666664 if (auto *MM = dyn_cast<MinMaxIntrinsic>(&CB)) {
0 commit comments