[llvm] [InstSimplify] Simplify `(fmul -x, +/-0)` -> `-/+0` (PR #85345)

via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 15 10:26:59 PDT 2024


================
@@ -5767,11 +5767,18 @@ static Value *simplifyFMAFMul(Value *Op0, Value *Op1, FastMathFlags FMF,
     if (FMF.noNaNs() && FMF.noSignedZeros())
       return ConstantFP::getZero(Op0->getType());
 
-    // +normal number * (-)0.0 --> (-)0.0
     KnownFPClass Known =
         computeKnownFPClass(Op0, FMF, fcInf | fcNan, /*Depth=*/0, Q);
-    if (Known.SignBit == false && Known.isKnownNever(fcInf | fcNan))
-      return Op1;
+    if (Known.isKnownNever(fcInf | fcNan)) {
+      // +normal number * (-)0.0 --> (-)0.0
+      if (Known.SignBit == false)
+        return Op1;
+      // -normal number * (-)0.0 --> -(-)0.0
+      if (Known.SignBit == true)
+        return match(Op1, m_PosZeroFP())
+                   ? ConstantFP::getNegativeZero(Op0->getType())
+                   : ConstantFP::getZero(Op0->getType());
----------------
goldsteinn wrote:

Switching to just `fneg`, that's necessary for handling mismatch vector.

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


More information about the llvm-commits mailing list