[APFloat][ADT] Fix sign handling logic for FMA results that truncate to zero.
[oota-llvm.git] / lib / Support / APFloat.cpp
index 295b16c55e207959e682952b8d3f347d23c4eafd..393ecf4784cb4a7fe299696d50b6e64c890c9f1a 100644 (file)
@@ -1823,7 +1823,7 @@ APFloat::fusedMultiplyAdd(const APFloat &multiplicand,
     /* If two numbers add (exactly) to zero, IEEE 754 decrees it is a
        positive zero unless rounding to minus infinity, except that
        adding two like-signed zeroes gives that zero.  */
-    if (category == fcZero && sign != addend.sign)
+    if (category == fcZero && !(fs & opUnderflow) && sign != addend.sign)
       sign = (rounding_mode == rmTowardNegative);
   } else {
     fs = multiplySpecials(multiplicand);