[llvm] [Instcombine]: Folds`llvm.ucmp` and `llvm.scmp` (PR #168505)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 29 06:56:09 PST 2025
================
@@ -4461,6 +4461,47 @@ static Value *simplifyWithOpsReplaced(Value *V,
return Absorber;
}
+ if (auto *CI = dyn_cast<CallInst>(I)) {
+ Function *F = CI->getCalledFunction();
+
+ // `x == y ? 0 : ucmp(x, y)` where under the replacement y -> x, `ucmp(x,
+ // x)` becomes `0`.
+ if (F && F->isIntrinsic() &&
+ (F->getIntrinsicID() == Intrinsic::scmp ||
+ F->getIntrinsicID() == Intrinsic::ucmp)) {
+ // If the call contains (an invalid) range attribute then a replacement
+ // might produce an unexpected poison value.
----------------
nikic wrote:
I'd rather not check the specifics here. Can we just use `hasPoisonGeneratingAnnotations()` here and add to DropFlags (see above)? That way the attribute is just going to be dropped if it's present.
https://github.com/llvm/llvm-project/pull/168505
More information about the llvm-commits
mailing list