Changes in directory llvm/include/llvm/ADT:
APInt.h updated: 1.57 -> 1.58 --- Log message: Compute getLowBitsSet correctly. Using the complement of a 64-bit value and shifting down without regard for the bitwidth of the APInt can lead to incorrect initialization values. Instead, check for the word size case (to avoid undef results from shift) and then do (1 << loBitsSet) - 1 --- Diffs of the changes: (+5 -4) APInt.h | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-) Index: llvm/include/llvm/ADT/APInt.h diff -u llvm/include/llvm/ADT/APInt.h:1.57 llvm/include/llvm/ADT/APInt.h:1.58 --- llvm/include/llvm/ADT/APInt.h:1.57 Sat Mar 24 20:13:46 2007 +++ llvm/include/llvm/ADT/APInt.h Sun Mar 25 16:58:42 2007 @@ -374,11 +374,12 @@ // Handle a degenerate case, to avoid shifting by word size if (loBitsSet == 0) return APInt(numBits, 0); - uint32_t shiftAmt = numBits - loBitsSet; + if (loBitsSet == APINT_BITS_PER_WORD) + return APInt(numBits, -1ULL); // For small values, return quickly - if (numBits <= APINT_BITS_PER_WORD) - return APInt(numBits, ~0ULL >> shiftAmt); - return (~APInt(numBits, 0)).lshr(shiftAmt); + if (numBits < APINT_BITS_PER_WORD) + return APInt(numBits, (1ULL << loBitsSet) - 1); + return (~APInt(numBits, 0)).lshr(numBits - loBitsSet); } /// The hash value is computed as the sum of the words and the bit width. _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits