[llvm] [ConstantValuePropagation] Fold calls to UCMP/SCMP when we know that ranges of operands do not overlap (PR #97235)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Sun Jun 30 21:39:09 PDT 2024
================
@@ -548,6 +548,27 @@ static bool processAbsIntrinsic(IntrinsicInst *II, LazyValueInfo *LVI) {
return false;
}
+static bool processCmpIntrinsic(IntrinsicInst *II, LazyValueInfo *LVI) {
+ bool IsSigned = II->getIntrinsicID() == Intrinsic::scmp;
+ ConstantRange LHS_CR = LVI->getConstantRangeAtUse(II->getOperandUse(0),
+ /*UndefAllowed*/ false);
+ ConstantRange RHS_CR = LVI->getConstantRangeAtUse(II->getOperandUse(1),
+ /*UndefAllowed*/ false);
+
+ if (LHS_CR.icmp(IsSigned ? ICmpInst::ICMP_SGT : ICmpInst::ICMP_UGT, RHS_CR)) {
+ II->replaceAllUsesWith(ConstantInt::get(II->getType(), 1));
+ II->eraseFromParent();
+ return true;
----------------
dtcxzyw wrote:
Please add statistics here.
https://github.com/llvm/llvm-project/pull/97235
More information about the llvm-commits
mailing list