mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-12 13:38:21 +00:00
Fix APFloat::convert so that it handles narrowing conversions correctly; it
was returning incorrect values in rare cases, and incorrectly marking exact conversions as inexact in some more common cases. Fixes PR11406, and a missed optimization in test/CodeGen/X86/fp-stack-O0.ll. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@145141 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -653,4 +653,28 @@ TEST(APFloatTest, getLargest) {
|
||||
EXPECT_EQ(1.7976931348623158e+308, APFloat::getLargest(APFloat::IEEEdouble).convertToDouble());
|
||||
}
|
||||
|
||||
TEST(APFloatTest, convert) {
|
||||
bool losesInfo;
|
||||
APFloat test(APFloat::IEEEdouble, "1.0");
|
||||
test.convert(APFloat::IEEEsingle, APFloat::rmNearestTiesToEven, &losesInfo);
|
||||
EXPECT_EQ(1.0f, test.convertToFloat());
|
||||
EXPECT_FALSE(losesInfo);
|
||||
|
||||
test = APFloat(APFloat::x87DoubleExtended, "0x1p-53");
|
||||
test.add(APFloat(APFloat::x87DoubleExtended, "1.0"), APFloat::rmNearestTiesToEven);
|
||||
test.convert(APFloat::IEEEdouble, APFloat::rmNearestTiesToEven, &losesInfo);
|
||||
EXPECT_EQ(1.0, test.convertToDouble());
|
||||
EXPECT_TRUE(losesInfo);
|
||||
|
||||
test = APFloat(APFloat::IEEEquad, "0x1p-53");
|
||||
test.add(APFloat(APFloat::IEEEquad, "1.0"), APFloat::rmNearestTiesToEven);
|
||||
test.convert(APFloat::IEEEdouble, APFloat::rmNearestTiesToEven, &losesInfo);
|
||||
EXPECT_EQ(1.0, test.convertToDouble());
|
||||
EXPECT_TRUE(losesInfo);
|
||||
|
||||
test = APFloat(APFloat::x87DoubleExtended, "0xf.fffffffp+28");
|
||||
test.convert(APFloat::IEEEdouble, APFloat::rmNearestTiesToEven, &losesInfo);
|
||||
EXPECT_EQ(4294967295.0, test.convertToDouble());
|
||||
EXPECT_FALSE(losesInfo);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user