mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-25 13:24:46 +00:00
[APFloat][ADT] Fix sign handling logic for FMA results that truncate to zero.
This patch adds a check for underflow when truncating results back to lower precision at the end of an FMA. The additional sign handling logic in APFloat::fusedMultiplyAdd should only be performed when the result of the addition step of the FMA (in full precision) is exactly zero, not when the result underflows to zero. Unit tests for this case and related signed zero FMA results are included. Fixes <rdar://problem/18925551>. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225123 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -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);
|
||||
|
Reference in New Issue
Block a user