llvm.org GIT mirror llvm / 5e55712
Fix APInt::countTrailingZeros to return BitWidth if the input is zero instead of returning some random large number. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44294 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 13 years ago
1 changed file(s) with 2 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
781781
782782 uint32_t APInt::countTrailingZeros() const {
783783 if (isSingleWord())
784 return CountTrailingZeros_64(VAL);
784 return std::min(CountTrailingZeros_64(VAL), BitWidth);
785785 uint32_t Count = 0;
786786 uint32_t i = 0;
787787 for (; i < getNumWords() && pVal[i] == 0; ++i)
788788 Count += APINT_BITS_PER_WORD;
789789 if (i < getNumWords())
790790 Count += CountTrailingZeros_64(pVal[i]);
791 return Count;
791 return std::min(Count, BitWidth);
792792 }
793793
794794 uint32_t APInt::countPopulation() const {