diff options
author | Stephen Canon <scanon@apple.com> | 2014-06-08 16:53:31 +0000 |
---|---|---|
committer | Stephen Canon <scanon@apple.com> | 2014-06-08 16:53:31 +0000 |
commit | d327828141855d7317116e9ef0bc74924b8527d9 (patch) | |
tree | 87a2a502b243a3a753ac71837c4505077a5a7651 /llvm/lib/Support/APFloat.cpp | |
parent | 960ea3f01831cd3f990e33e3658f58b12906917c (diff) | |
download | bcm5719-llvm-d327828141855d7317116e9ef0bc74924b8527d9.tar.gz bcm5719-llvm-d327828141855d7317116e9ef0bc74924b8527d9.zip |
APFloat: x - NaN needs to flip the signbit of NaN when x is a number.
Because we don't have a separate negate( ) function, 0 - NaN does double-duty as the IEEE-754 negate( ) operation, which (unlike most FP ops) *does* attach semantic meaning to the signbit of NaN.
llvm-svn: 210428
Diffstat (limited to 'llvm/lib/Support/APFloat.cpp')
-rw-r--r-- | llvm/lib/Support/APFloat.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/llvm/lib/Support/APFloat.cpp b/llvm/lib/Support/APFloat.cpp index f9fe09541db..7989e30afae 100644 --- a/llvm/lib/Support/APFloat.cpp +++ b/llvm/lib/Support/APFloat.cpp @@ -1372,7 +1372,9 @@ APFloat::addOrSubtractSpecials(const APFloat &rhs, bool subtract) case PackCategoriesIntoKey(fcZero, fcNaN): case PackCategoriesIntoKey(fcNormal, fcNaN): case PackCategoriesIntoKey(fcInfinity, fcNaN): - sign = false; + // We need to be sure to flip the sign here for subtraction because we + // don't have a separate negate operation so -NaN becomes 0 - NaN here. + sign = rhs.sign ^ subtract; category = fcNaN; copySignificand(rhs); return opOK; |