llvm.org GIT mirror llvm / 6b370e6
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167582 91177308-0d34-0410-b5e6-96231b3b80d8 Benjamin Kramer 7 years ago
2 changed file(s) with 6 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
35523552 }
35533553
35543554 bool APFloat::getExactInverse(APFloat *inv) const {
3555 // We can only guarantee the existence of an exact inverse for IEEE floats.
3556 if (semantics != &IEEEhalf && semantics != &IEEEsingle &&
3557 semantics != &IEEEdouble && semantics != &IEEEquad)
3558 return false;
3559
35603555 // Special floats and denormals have no exact inverse.
35613556 if (category != fcNormal)
35623557 return false;
634634 EXPECT_TRUE(inv.bitwiseIsEqual(APFloat(0.5)));
635635 EXPECT_TRUE(APFloat(2.0f).getExactInverse(&inv));
636636 EXPECT_TRUE(inv.bitwiseIsEqual(APFloat(0.5f)));
637 EXPECT_TRUE(APFloat(APFloat::IEEEquad, "2.0").getExactInverse(&inv));
638 EXPECT_TRUE(inv.bitwiseIsEqual(APFloat(APFloat::IEEEquad, "0.5")));
639 EXPECT_TRUE(APFloat(APFloat::PPCDoubleDouble, "2.0").getExactInverse(&inv));
640 EXPECT_TRUE(inv.bitwiseIsEqual(APFloat(APFloat::PPCDoubleDouble, "0.5")));
641 EXPECT_TRUE(APFloat(APFloat::x87DoubleExtended, "2.0").getExactInverse(&inv));
642 EXPECT_TRUE(inv.bitwiseIsEqual(APFloat(APFloat::x87DoubleExtended, "0.5")));
637643
638644 // FLT_MIN
639645 EXPECT_TRUE(APFloat(1.17549435e-38f).getExactInverse(&inv));