[PATCH] D36961: [APFloat] Fix IsInteger() for DoubleAPFloat
Davide Italiano via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 21 08:15:07 PDT 2017
davide created this revision.
I'm not sure anybody was using it as the implementation would always assert (as the PR https://bugs.llvm.org/show_bug.cgi?id=34098 shows).
https://reviews.llvm.org/D36961
Files:
lib/Support/APFloat.cpp
unittests/ADT/APFloatTest.cpp
Index: unittests/ADT/APFloatTest.cpp
===================================================================
--- unittests/ADT/APFloatTest.cpp
+++ unittests/ADT/APFloatTest.cpp
@@ -1349,6 +1349,19 @@
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());
+}
+
TEST(APFloatTest, getLargest) {
EXPECT_EQ(3.402823466e+38f, APFloat::getLargest(APFloat::IEEEsingle()).convertToFloat());
EXPECT_EQ(1.7976931348623158e+308, APFloat::getLargest(APFloat::IEEEdouble()).convertToDouble());
Index: lib/Support/APFloat.cpp
===================================================================
--- lib/Support/APFloat.cpp
+++ 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,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D36961.111979.patch
Type: text/x-patch
Size: 1486 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170821/0f3e0143/attachment.bin>
More information about the llvm-commits
mailing list