llvm.org GIT mirror llvm / 9e513ac
Fix PR1816, by correcting the broken definition of APInt::countTrailingZeros. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44296 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 12 years ago
3 changed file(s) with 12 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
895895 /// countLeadingZeros - This function is an APInt version of the
896896 /// countLeadingZeros_{32,64} functions in MathExtras.h. It counts the number
897897 /// of zeros from the most significant bit to the first one bit.
898 /// @returns getNumWords() * APINT_BITS_PER_WORD if the value is zero.
898 /// @returns BitWidth if the value is zero.
899899 /// @returns the number of zeros from the most significant bit to the first
900900 /// one bits.
901 /// @brief Count the number of leading one bits.
902901 uint32_t countLeadingZeros() const;
903902
904903 /// countLeadingOnes - This function counts the number of contiguous 1 bits
910909
911910 /// countTrailingZeros - This function is an APInt version of the
912911 /// countTrailingZoers_{32,64} functions in MathExtras.h. It counts
913 /// the number of zeros from the least significant bit to the first one bit.
914 /// @returns getNumWords() * APINT_BITS_PER_WORD if the value is zero.
912 /// the number of zeros from the least significant bit to the first set bit.
913 /// @returns BitWidth if the value is zero.
915914 /// @returns the number of zeros from the least significant bit to the first
916915 /// one bit.
917916 /// @brief Count the number of trailing zero bits.
744744 uint32_t remainder = BitWidth % APINT_BITS_PER_WORD;
745745 if (remainder)
746746 Count -= APINT_BITS_PER_WORD - remainder;
747 return Count;
747 return std::min(Count, BitWidth);
748748 }
749749
750750 static uint32_t countLeadingOnes_64(uint64_t V, uint32_t skip) {
0 ; RUN: llvm-as < %s | opt -constprop | llvm-dis | grep {ret i13 13}
1 ; PR1816
2 declare i13 @llvm.cttz.i13(i13)
3
4 define i13 @test() {
5 %X = call i13 @llvm.cttz.i13(i13 0)
6 ret i13 %X
7 }