[llvm] [InstSimplify] Implement simple folds for `ucmp`/`scmp` intrinsics (PR #95601)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Sat Jun 15 13:11:28 PDT 2024
================
@@ -6505,6 +6505,33 @@ Value *llvm::simplifyBinaryIntrinsic(Intrinsic::ID IID, Type *ReturnType,
break;
}
+ case Intrinsic::scmp:
+ case Intrinsic::ucmp: {
+ // Fold cmp x, x -> 0
+ if (Op0 == Op1)
+ return Constant::getNullValue(ReturnType);
+
+ // Fold to a constant if the relationship between operands can be
+ // established with certainty
+ if (isICmpTrue(CmpInst::ICMP_EQ, Op0, Op1, Q, RecursionLimit))
----------------
dtcxzyw wrote:
See https://github.com/llvm/llvm-project/blob/355e4a9e56c644f24fc10f780cb2fc68b660d0a0/llvm/lib/Analysis/InstructionSimplify.cpp#L6498-L6503
There is no negative test which blocks undef fold in https://reviews.llvm.org/D85929.
https://github.com/llvm/llvm-project/pull/95601
More information about the llvm-commits
mailing list