[PATCH] D36961: [APFloat] Fix IsInteger() for DoubleAPFloat
Davide Italiano via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 21 09:53:11 PDT 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL311351: [APFloat] Fix IsInteger() for DoubleAPFloat. (authored by davide).
Changed prior to commit:
https://reviews.llvm.org/D36961?vs=111979&id=112007#toc
Repository:
rL LLVM
https://reviews.llvm.org/D36961
Files:
llvm/trunk/lib/Support/APFloat.cpp
llvm/trunk/unittests/ADT/APFloatTest.cpp
Index: llvm/trunk/lib/Support/APFloat.cpp
===================================================================
--- llvm/trunk/lib/Support/APFloat.cpp
+++ llvm/trunk/lib/Support/APFloat.cpp
@@ -4363,10 +4363,7 @@
bool DoubleAPFloat::isInteger() const {
assert(Semantics == &semPPCDoubleDouble && "Unexpected Semantics");
- APFloat Tmp(semPPCDoubleDoubleLegacy);
- (void)Tmp.add(Floats[0], rmNearestTiesToEven);
- (void)Tmp.add(Floats[1], rmNearestTiesToEven);
- return Tmp.isInteger();
+ return Floats[0].isInteger() && Floats[1].isInteger();
}
void DoubleAPFloat::toString(SmallVectorImpl<char> &Str,
Index: llvm/trunk/unittests/ADT/APFloatTest.cpp
===================================================================
--- llvm/trunk/unittests/ADT/APFloatTest.cpp
+++ llvm/trunk/unittests/ADT/APFloatTest.cpp
@@ -1349,6 +1349,24 @@
EXPECT_TRUE(T.isInteger());
}
+TEST(DoubleAPFloatTest, isInteger) {
+ APFloat F1(-0.0);
+ APFloat F2(-0.0);
+ llvm::detail::DoubleAPFloat T(APFloat::PPCDoubleDouble(), std::move(F1),
+ std::move(F2));
+ EXPECT_TRUE(T.isInteger());
+ APFloat F3(3.14159);
+ APFloat F4(-0.0);
+ llvm::detail::DoubleAPFloat T2(APFloat::PPCDoubleDouble(), std::move(F3),
+ std::move(F4));
+ EXPECT_FALSE(T2.isInteger());
+ APFloat F5(-0.0);
+ APFloat F6(3.14159);
+ llvm::detail::DoubleAPFloat T3(APFloat::PPCDoubleDouble(), std::move(F5),
+ std::move(F6));
+ EXPECT_FALSE(T3.isInteger());
+}
+
TEST(APFloatTest, getLargest) {
EXPECT_EQ(3.402823466e+38f, APFloat::getLargest(APFloat::IEEEsingle()).convertToFloat());
EXPECT_EQ(1.7976931348623158e+308, APFloat::getLargest(APFloat::IEEEdouble()).convertToDouble());
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D36961.112007.patch
Type: text/x-patch
Size: 1756 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170821/c207017a/attachment.bin>
More information about the llvm-commits
mailing list