diff options
author | Lang Hames <lhames@gmail.com> | 2015-01-04 01:20:55 +0000 |
---|---|---|
committer | Lang Hames <lhames@gmail.com> | 2015-01-04 01:20:55 +0000 |
commit | 12b12e800b04404c3763ebcef2168c429921f04e (patch) | |
tree | 23a9262a87767cbbd08d46da7831b230c0d52cba /llvm/lib | |
parent | 744cc5b5dd90613eb84c21f8288bf5d1fa9cee85 (diff) | |
download | bcm5719-llvm-12b12e800b04404c3763ebcef2168c429921f04e.tar.gz bcm5719-llvm-12b12e800b04404c3763ebcef2168c429921f04e.zip |
[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>.
llvm-svn: 225123
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Support/APFloat.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/llvm/lib/Support/APFloat.cpp b/llvm/lib/Support/APFloat.cpp index 295b16c55e2..393ecf4784c 100644 --- a/llvm/lib/Support/APFloat.cpp +++ b/llvm/lib/Support/APFloat.cpp @@ -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); |