summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/include/llvm/ADT/APInt.h2
-rw-r--r--llvm/unittests/ADT/APIntTest.cpp10
2 files changed, 10 insertions, 2 deletions
diff --git a/llvm/include/llvm/ADT/APInt.h b/llvm/include/llvm/ADT/APInt.h
index fa4233a0aa9..21be50aa49c 100644
--- a/llvm/include/llvm/ADT/APInt.h
+++ b/llvm/include/llvm/ADT/APInt.h
@@ -538,8 +538,6 @@ public:
// Handle a degenerate case, to avoid shifting by word size
if (loBitsSet == 0)
return APInt(numBits, 0);
- if (loBitsSet == APINT_BITS_PER_WORD)
- return APInt(numBits, UINT64_MAX);
// For small values, return quickly.
if (loBitsSet <= APINT_BITS_PER_WORD)
return APInt(numBits, UINT64_MAX >> (APINT_BITS_PER_WORD - loBitsSet));
diff --git a/llvm/unittests/ADT/APIntTest.cpp b/llvm/unittests/ADT/APIntTest.cpp
index 30da181a105..fa499bdf22b 100644
--- a/llvm/unittests/ADT/APIntTest.cpp
+++ b/llvm/unittests/ADT/APIntTest.cpp
@@ -1521,3 +1521,13 @@ TEST(APIntTest, extractBits) {
EXPECT_EQ(static_cast<int64_t>(0xFFFFFFFFFF80007Full),
i257.extractBits(129, 1).getSExtValue());
}
+
+TEST(APIntTest, getLowBitsSet) {
+ APInt i128lo64 = APInt::getLowBitsSet(128, 64);
+ EXPECT_EQ(0u, i128lo64.countLeadingOnes());
+ EXPECT_EQ(64u, i128lo64.countLeadingZeros());
+ EXPECT_EQ(64u, i128lo64.getActiveBits());
+ EXPECT_EQ(0u, i128lo64.countTrailingZeros());
+ EXPECT_EQ(64u, i128lo64.countTrailingOnes());
+ EXPECT_EQ(64u, i128lo64.countPopulation());
+}
OpenPOWER on IntegriCloud