summaryrefslogtreecommitdiff
path: root/lib/Support
diff options
context:
space:
mode:
authorStephen Canon <scanon@apple.com>2014-06-08 16:53:31 +0000
committerStephen Canon <scanon@apple.com>2014-06-08 16:53:31 +0000
commitbef256f49b77b17503b23699466d9bfc2f02d65f (patch)
tree97f574bcfe3cd4b3f4bfcdcb2b576f2dc7721550 /lib/Support
parentc50f986b4d8ecbf3437c67e987e26e268ef5f06a (diff)
downloadllvm-bef256f49b77b17503b23699466d9bfc2f02d65f.tar.gz
llvm-bef256f49b77b17503b23699466d9bfc2f02d65f.tar.bz2
llvm-bef256f49b77b17503b23699466d9bfc2f02d65f.tar.xz
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210428 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support')
-rw-r--r--lib/Support/APFloat.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/Support/APFloat.cpp b/lib/Support/APFloat.cpp
index f9fe09541d..7989e30afa 100644
--- a/lib/Support/APFloat.cpp
+++ b/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;