[llvm] [InstSimplify] Add constant folding support for `ucmp`/`scmp` intrinsics (PR #93730)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Wed May 29 13:25:47 PDT 2024
================
@@ -2764,6 +2766,33 @@ static Constant *ConstantFoldIntrinsicCall2(Intrinsic::ID IntrinsicID, Type *Ty,
? *C0
: *C1);
+ case Intrinsic::scmp:
+ case Intrinsic::ucmp:
+ if (isa<PoisonValue>(Operands[0]) || isa<PoisonValue>(Operands[1]))
+ return PoisonValue::get(Ty);
+
+ if (!C0 || !C1)
+ return UndefValue::get(Ty);
----------------
nikic wrote:
This is incorrect. This would mean that the return value can be *any* value, while only -1, 1 and 0 are legal. You can return one of them instead (0 would be the preferred choice).
https://github.com/llvm/llvm-project/pull/93730
More information about the llvm-commits
mailing list