forked from OSchip/llvm-project
Fix APInt::countTrailingZeros to return BitWidth if the input is zero instead of returning some random large number.
llvm-svn: 44294
This commit is contained in:
parent
0cf083815a
commit
c2c4c7456c
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue