diff options
| author | Craig Topper <craig.topper@gmail.com> | 2017-02-26 19:28:48 +0000 |
|---|---|---|
| committer | Craig Topper <craig.topper@gmail.com> | 2017-02-26 19:28:48 +0000 |
| commit | 7d7b6d767dd9962fb6b1779dfc237a617a4a794b (patch) | |
| tree | d57f3c075f9e5bd9999c0949636bd06aa0b82ec1 /llvm | |
| parent | a8b26b87151dde66a9e3e05686a5c6b6ecefacf8 (diff) | |
| download | bcm5719-llvm-7d7b6d767dd9962fb6b1779dfc237a617a4a794b.tar.gz bcm5719-llvm-7d7b6d767dd9962fb6b1779dfc237a617a4a794b.zip | |
[APInt] Use UINT64_MAX instead of ~0ULL. NFC
llvm-svn: 296300
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/include/llvm/ADT/APInt.h | 4 | ||||
| -rw-r--r-- | llvm/unittests/ADT/APIntTest.cpp | 10 |
2 files changed, 12 insertions, 2 deletions
diff --git a/llvm/include/llvm/ADT/APInt.h b/llvm/include/llvm/ADT/APInt.h index 21be50aa49c..ccbff7a5daf 100644 --- a/llvm/include/llvm/ADT/APInt.h +++ b/llvm/include/llvm/ADT/APInt.h @@ -406,7 +406,7 @@ public: /// If this value is smaller than the specified limit, return it, otherwise /// return the limit value. This causes the value to saturate to the limit. - uint64_t getLimitedValue(uint64_t Limit = ~0ULL) const { + uint64_t getLimitedValue(uint64_t Limit = UINT64_MAX) const { return (getActiveBits() > 64 || getZExtValue() > Limit) ? Limit : getZExtValue(); } @@ -523,7 +523,7 @@ public: unsigned shiftAmt = numBits - hiBitsSet; // For small values, return quickly if (numBits <= APINT_BITS_PER_WORD) - return APInt(numBits, ~0ULL << shiftAmt); + return APInt(numBits, UINT64_MAX << shiftAmt); return getAllOnesValue(numBits).shl(shiftAmt); } diff --git a/llvm/unittests/ADT/APIntTest.cpp b/llvm/unittests/ADT/APIntTest.cpp index fa499bdf22b..a818d26787e 100644 --- a/llvm/unittests/ADT/APIntTest.cpp +++ b/llvm/unittests/ADT/APIntTest.cpp @@ -1531,3 +1531,13 @@ TEST(APIntTest, getLowBitsSet) { EXPECT_EQ(64u, i128lo64.countTrailingOnes()); EXPECT_EQ(64u, i128lo64.countPopulation()); } + +TEST(APIntTest, getHighBitsSet) { + APInt i64hi32 = APInt::getHighBitsSet(64, 32); + EXPECT_EQ(32u, i64hi32.countLeadingOnes()); + EXPECT_EQ(0u, i64hi32.countLeadingZeros()); + EXPECT_EQ(64u, i64hi32.getActiveBits()); + EXPECT_EQ(32u, i64hi32.countTrailingZeros()); + EXPECT_EQ(0u, i64hi32.countTrailingOnes()); + EXPECT_EQ(32u, i64hi32.countPopulation()); +} |

