Author: lattner Date: Fri Nov 23 16:36:25 2007 New Revision: 44294 URL: http://llvm.org/viewvc/llvm-project?rev=44294&view=rev Log: Fix APInt::countTrailingZeros to return BitWidth if the input is zero instead of returning some random large number.
Modified: llvm/trunk/lib/Support/APInt.cpp Modified: llvm/trunk/lib/Support/APInt.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/APInt.cpp?rev=44294&r1=44293&r2=44294&view=diff ============================================================================== --- llvm/trunk/lib/Support/APInt.cpp (original) +++ llvm/trunk/lib/Support/APInt.cpp Fri Nov 23 16:36:25 2007 @@ -782,14 +782,14 @@ 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 { _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits