/// countLeadingZeros - This function is an APInt version of the
/// countLeadingZeros_{32,64} functions in MathExtras.h. It counts the number
/// of zeros from the most significant bit to the first one bit.
- /// @returns getNumWords() * APINT_BITS_PER_WORD if the value is zero.
+ /// @returns BitWidth if the value is zero.
/// @returns the number of zeros from the most significant bit to the first
/// one bits.
- /// @brief Count the number of leading one bits.
uint32_t countLeadingZeros() const;
/// countLeadingOnes - This function counts the number of contiguous 1 bits
/// countTrailingZeros - This function is an APInt version of the
/// countTrailingZoers_{32,64} functions in MathExtras.h. It counts
- /// the number of zeros from the least significant bit to the first one bit.
- /// @returns getNumWords() * APINT_BITS_PER_WORD if the value is zero.
+ /// the number of zeros from the least significant bit to the first set bit.
+ /// @returns BitWidth if the value is zero.
/// @returns the number of zeros from the least significant bit to the first
/// one bit.
/// @brief Count the number of trailing zero bits.
uint32_t remainder = BitWidth % APINT_BITS_PER_WORD;
if (remainder)
Count -= APINT_BITS_PER_WORD - remainder;
- return Count;
+ return std::min(Count, BitWidth);
}
static uint32_t countLeadingOnes_64(uint64_t V, uint32_t skip) {
--- /dev/null
+; RUN: llvm-as < %s | opt -constprop | llvm-dis | grep {ret i13 13}
+; PR1816
+declare i13 @llvm.cttz.i13(i13)
+
+define i13 @test() {
+ %X = call i13 @llvm.cttz.i13(i13 0)
+ ret i13 %X
+}