diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2013-01-25 17:01:00 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2013-01-25 17:01:00 +0000 |
commit | b361adbb64535677d617e2680b06cc0283b07d1a (patch) | |
tree | 95c5ed64fe9b879e7dfd7105856411b724a8e99c /llvm/lib/Support/APFloat.cpp | |
parent | 5548879324813b8fa74d1c67e08a2e00ead7785f (diff) | |
download | bcm5719-llvm-b361adbb64535677d617e2680b06cc0283b07d1a.tar.gz bcm5719-llvm-b361adbb64535677d617e2680b06cc0283b07d1a.zip |
APFloat: Make sure that we get a well-formed x87 NaN when converting from a smaller type.
Fixes PR15054.
llvm-svn: 173459
Diffstat (limited to 'llvm/lib/Support/APFloat.cpp')
-rw-r--r-- | llvm/lib/Support/APFloat.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/lib/Support/APFloat.cpp b/llvm/lib/Support/APFloat.cpp index 686f91b0873..5b68fbb2705 100644 --- a/llvm/lib/Support/APFloat.cpp +++ b/llvm/lib/Support/APFloat.cpp @@ -1913,6 +1913,12 @@ APFloat::convert(const fltSemantics &toSemantics, *losesInfo = (fs != opOK); } else if (category == fcNaN) { *losesInfo = lostFraction != lfExactlyZero || X86SpecialNan; + + // For x87 extended precision, we want to make a NaN, not a special NaN if + // the input wasn't special either. + if (!X86SpecialNan && semantics == &APFloat::x87DoubleExtended) + APInt::tcSetBit(significandParts(), semantics->precision - 1); + // gcc forces the Quiet bit on, which means (float)(double)(float_sNan) // does not give you back the same bits. This is dubious, and we // don't currently do it. You're really supposed to get |