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 /unittests/ADT/APFloatTest.cpp | |
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 'unittests/ADT/APFloatTest.cpp')
-rw-r--r-- | unittests/ADT/APFloatTest.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/unittests/ADT/APFloatTest.cpp b/unittests/ADT/APFloatTest.cpp index 7345e12..2789835 100644 --- a/unittests/ADT/APFloatTest.cpp +++ b/unittests/ADT/APFloatTest.cpp @@ -794,6 +794,32 @@ TEST(APFloatTest, convert) { test.convert(APFloat::IEEEdouble, APFloat::rmNearestTiesToEven, &losesInfo); EXPECT_EQ(4294967295.0, test.convertToDouble()); EXPECT_FALSE(losesInfo); + + test = APFloat::getSNaN(APFloat::IEEEsingle); + APFloat X87SNaN = APFloat::getSNaN(APFloat::x87DoubleExtended); + test.convert(APFloat::x87DoubleExtended, APFloat::rmNearestTiesToEven, + &losesInfo); + EXPECT_TRUE(test.bitwiseIsEqual(X87SNaN)); + EXPECT_FALSE(losesInfo); + + test = APFloat::getQNaN(APFloat::IEEEsingle); + APFloat X87QNaN = APFloat::getQNaN(APFloat::x87DoubleExtended); + test.convert(APFloat::x87DoubleExtended, APFloat::rmNearestTiesToEven, + &losesInfo); + EXPECT_TRUE(test.bitwiseIsEqual(X87QNaN)); + EXPECT_FALSE(losesInfo); + + test = APFloat::getSNaN(APFloat::x87DoubleExtended); + test.convert(APFloat::x87DoubleExtended, APFloat::rmNearestTiesToEven, + &losesInfo); + EXPECT_TRUE(test.bitwiseIsEqual(X87SNaN)); + EXPECT_FALSE(losesInfo); + + test = APFloat::getQNaN(APFloat::x87DoubleExtended); + test.convert(APFloat::x87DoubleExtended, APFloat::rmNearestTiesToEven, + &losesInfo); + EXPECT_TRUE(test.bitwiseIsEqual(X87QNaN)); + EXPECT_FALSE(losesInfo); } TEST(APFloatTest, PPCDoubleDouble) { |