diff options
author | Craig Topper <craig.topper@gmail.com> | 2017-02-26 19:28:45 +0000 |
---|---|---|
committer | Craig Topper <craig.topper@gmail.com> | 2017-02-26 19:28:45 +0000 |
commit | a8b26b87151dde66a9e3e05686a5c6b6ecefacf8 (patch) | |
tree | 3f662277fc867bb62af6114f301b084d7e2682eb | |
parent | 3ca169f3a92d4e57ff725428c26e6d73ad0e809b (diff) | |
download | bcm5719-llvm-a8b26b87151dde66a9e3e05686a5c6b6ecefacf8.tar.gz bcm5719-llvm-a8b26b87151dde66a9e3e05686a5c6b6ecefacf8.zip |
[APInt] Remove unnecessary early out from getLowBitsSet. The same case is handled equally well by the next check.
llvm-svn: 296299
-rw-r--r-- | llvm/include/llvm/ADT/APInt.h | 2 | ||||
-rw-r--r-- | llvm/unittests/ADT/APIntTest.cpp | 10 |
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()); +} |