[llvm-commits] [llvm] r44296 - in /llvm/trunk: include/llvm/ADT/APInt.h lib/Support/APInt.cpp test/Transforms/ConstProp/2007-11-23-cttz.ll
Chris Lattner
sabre at nondot.org
Fri Nov 23 14:42:31 PST 2007
Author: lattner
Date: Fri Nov 23 16:42:31 2007
New Revision: 44296
URL: http://llvm.org/viewvc/llvm-project?rev=44296&view=rev
Log:
Fix PR1816, by correcting the broken definition of APInt::countTrailingZeros.
Added:
llvm/trunk/test/Transforms/ConstProp/2007-11-23-cttz.ll
Modified:
llvm/trunk/include/llvm/ADT/APInt.h
llvm/trunk/lib/Support/APInt.cpp
Modified: llvm/trunk/include/llvm/ADT/APInt.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/APInt.h?rev=44296&r1=44295&r2=44296&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/APInt.h (original)
+++ llvm/trunk/include/llvm/ADT/APInt.h Fri Nov 23 16:42:31 2007
@@ -896,10 +896,9 @@
/// 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
@@ -911,8 +910,8 @@
/// 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.
Modified: llvm/trunk/lib/Support/APInt.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/APInt.cpp?rev=44296&r1=44295&r2=44296&view=diff
==============================================================================
--- llvm/trunk/lib/Support/APInt.cpp (original)
+++ llvm/trunk/lib/Support/APInt.cpp Fri Nov 23 16:42:31 2007
@@ -745,7 +745,7 @@
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) {
Added: llvm/trunk/test/Transforms/ConstProp/2007-11-23-cttz.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/ConstProp/2007-11-23-cttz.ll?rev=44296&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/ConstProp/2007-11-23-cttz.ll (added)
+++ llvm/trunk/test/Transforms/ConstProp/2007-11-23-cttz.ll Fri Nov 23 16:42:31 2007
@@ -0,0 +1,8 @@
+; 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
+}
More information about the llvm-commits
mailing list