diff options
author | Chris Lattner <sabre@nondot.org> | 2007-11-23 22:36:25 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2007-11-23 22:36:25 +0000 |
commit | c2c4c7456c50f5a10d7328a993c831799a61f7a9 (patch) | |
tree | ad48a6d46c48534755fab9a8766904e24bf510f9 /llvm/lib/Support/APInt.cpp | |
parent | 0cf083815abc00f7b206762337df58e0df8ced95 (diff) | |
download | bcm5719-llvm-c2c4c7456c50f5a10d7328a993c831799a61f7a9.tar.gz bcm5719-llvm-c2c4c7456c50f5a10d7328a993c831799a61f7a9.zip |
Fix APInt::countTrailingZeros to return BitWidth if the input is zero instead of returning some random large number.
llvm-svn: 44294
Diffstat (limited to 'llvm/lib/Support/APInt.cpp')
-rw-r--r-- | llvm/lib/Support/APInt.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/llvm/lib/Support/APInt.cpp b/llvm/lib/Support/APInt.cpp index c5abf4bf163..7af0101ece8 100644 --- a/llvm/lib/Support/APInt.cpp +++ b/llvm/lib/Support/APInt.cpp @@ -782,14 +782,14 @@ uint32_t APInt::countLeadingOnes() const { uint32_t APInt::countTrailingZeros() const { if (isSingleWord()) - return CountTrailingZeros_64(VAL); + return std::min(CountTrailingZeros_64(VAL), BitWidth); uint32_t Count = 0; uint32_t i = 0; for (; i < getNumWords() && pVal[i] == 0; ++i) Count += APINT_BITS_PER_WORD; if (i < getNumWords()) Count += CountTrailingZeros_64(pVal[i]); - return Count; + return std::min(Count, BitWidth); } uint32_t APInt::countPopulation() const { |