forked from OSchip/llvm-project
Drop the limitation to IEEE floating point types from the fdiv of pow2 -> fmul transform.
This is safe for x87 long doubles and ppc double doubles too. llvm-svn: 167582
This commit is contained in:
parent
9b836fb019
commit
08be41adbf
|
@ -3553,11 +3553,6 @@ void APFloat::toString(SmallVectorImpl<char> &Str,
|
|||
}
|
||||
|
||||
bool APFloat::getExactInverse(APFloat *inv) const {
|
||||
// We can only guarantee the existence of an exact inverse for IEEE floats.
|
||||
if (semantics != &IEEEhalf && semantics != &IEEEsingle &&
|
||||
semantics != &IEEEdouble && semantics != &IEEEquad)
|
||||
return false;
|
||||
|
||||
// Special floats and denormals have no exact inverse.
|
||||
if (category != fcNormal)
|
||||
return false;
|
||||
|
|
|
@ -635,6 +635,12 @@ TEST(APFloatTest, exactInverse) {
|
|||
EXPECT_TRUE(inv.bitwiseIsEqual(APFloat(0.5)));
|
||||
EXPECT_TRUE(APFloat(2.0f).getExactInverse(&inv));
|
||||
EXPECT_TRUE(inv.bitwiseIsEqual(APFloat(0.5f)));
|
||||
EXPECT_TRUE(APFloat(APFloat::IEEEquad, "2.0").getExactInverse(&inv));
|
||||
EXPECT_TRUE(inv.bitwiseIsEqual(APFloat(APFloat::IEEEquad, "0.5")));
|
||||
EXPECT_TRUE(APFloat(APFloat::PPCDoubleDouble, "2.0").getExactInverse(&inv));
|
||||
EXPECT_TRUE(inv.bitwiseIsEqual(APFloat(APFloat::PPCDoubleDouble, "0.5")));
|
||||
EXPECT_TRUE(APFloat(APFloat::x87DoubleExtended, "2.0").getExactInverse(&inv));
|
||||
EXPECT_TRUE(inv.bitwiseIsEqual(APFloat(APFloat::x87DoubleExtended, "0.5")));
|
||||
|
||||
// FLT_MIN
|
||||
EXPECT_TRUE(APFloat(1.17549435e-38f).getExactInverse(&inv));
|
||||
|
|
Loading…
Reference in New Issue