[ADT] Fix PR20728 - Incorrect APFloat::fusedMultiplyAdd results for x86_fp80.
authorLang Hames <lhames@gmail.com>
Wed, 19 Nov 2014 19:15:41 +0000 (19:15 +0000)
committerLang Hames <lhames@gmail.com>
Wed, 19 Nov 2014 19:15:41 +0000 (19:15 +0000)
commit58c62e1dba9b9104cba04044d8c1678632bae729
treedd4f8b6a7d2ae43b2b0d742cd776903d87c69042
parente0bb2f31b2b23acb1ee179f8bd8f972c39f9e49d
[ADT] Fix PR20728 - Incorrect APFloat::fusedMultiplyAdd results for x86_fp80.

As detailed at http://llvm.org/PR20728, due to an internal overflow in
APFloat::multiplySignificand the APFloat::fusedMultiplyAdd method can return
incorrect results for x87DoubleExtended (x86_fp80) values. This commonly
manifests as incorrect constant folding of libm fmal calls on x86. E.g.

fmal(1.0L, 1.0L, 3.0L) == 0.0L      (should be 4.0L)

This patch fixes PR20728 by adding an extra bit to the significand for
intermediate results of APFloat::multiplySignificand, avoiding the overflow.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222374 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Support/APFloat.cpp
unittests/ADT/APFloatTest.cpp