[llvm] [instcombine][x86]: simplifyx86fpmaxmin - allow negzero for single operand (PR #180418)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Sat Feb 14 03:36:56 PST 2026


================
@@ -1745,15 +1745,22 @@ static Value *simplifyX86FPMaxMin(const IntrinsicInst &II, InstCombiner &IC,
   APInt DemandedElts =
       IsScalar ? APInt::getOneBitSet(VWidth, 0) : APInt::getAllOnes(VWidth);
 
-  // Verify that the inputs are not one of (NaN, Inf, Subnormal, NegZero),
-  // otherwise we cannot safely generalize to MAXNUM/MINNUM.
-  FPClassTest Forbidden = fcNan | fcInf | fcSubnormal | fcNegZero;
+  FPClassTest Forbidden0 = fcNan | fcInf | fcSubnormal;
+  FPClassTest Forbidden1 = fcNan | fcInf | fcSubnormal;
+  if (NewIID == Intrinsic::maxnum) {
+    // For maxnum, only forbid NegZero in the second operand.
+    Forbidden1 |= fcNegZero;
+  } else if (NewIID == Intrinsic::minnum) {
----------------
RKSimon wrote:

(style) replace this with:
```
} else {
  assert(NewIID == Intrinsic::minnum && "unknown intrinsic");
...
}
```

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


More information about the llvm-commits mailing list