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 | bd7561ea29649625775ef814dded2856d91c4dcf (patch) | |
tree | 0ab4354fbba1ae8def6c55bfed13d12911e6ac13 /lib/Support | |
parent | 5b7c05716791adba09bb342f10c5af2c702c675d (diff) | |
download | external_llvm-bd7561ea29649625775ef814dded2856d91c4dcf.zip external_llvm-bd7561ea29649625775ef814dded2856d91c4dcf.tar.gz external_llvm-bd7561ea29649625775ef814dded2856d91c4dcf.tar.bz2 |
APFloat: Make sure that we get a well-formed x87 NaN when converting from a smaller type.
Fixes PR15054.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173459 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support')
-rw-r--r-- | lib/Support/APFloat.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/Support/APFloat.cpp b/lib/Support/APFloat.cpp index 686f91b..5b68fbb 100644 --- a/lib/Support/APFloat.cpp +++ b/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 |