[llvm] [InstCombine] Don't convert a compare+select into a minnum/maxnum intrinsic that can't be lowered back to a compare+select (PR #177821)

via llvm-commits llvm-commits at lists.llvm.org
Sun Jan 25 12:29:24 PST 2026


================
@@ -4357,7 +4357,21 @@ Instruction *InstCombinerImpl::visitSelectInst(SelectInst &SI) {
 
     // Canonicalize select of FP values where NaN and -0.0 are not valid as
     // minnum/maxnum intrinsics.
-    if (SIFPOp->hasNoNaNs() &&
+    if (FCmp && SIFPOp->hasNoNaNs() &&
+        // In order to preserve the nnan flag on the generated intrinsic call,
+        // the nnan flag must be present on both the compare *and* the select
----------------
valadaptive wrote:

I thought I tested this in Alive2, but I tried it again and you're right.

https://github.com/llvm/llvm-project/pull/177821


More information about the llvm-commits mailing list