Changes in directory llvm/lib/Support:
APInt.cpp updated: 1.79 -> 1.80 --- Log message: Fix shl to produce the correct result when the bitwidth is > 64 and the shift amount is 0. Previously this code would do a lshr by the bit width which can lead to incorrect results. --- Diffs of the changes: (+6 -0) APInt.cpp | 6 ++++++ 1 files changed, 6 insertions(+) Index: llvm/lib/Support/APInt.cpp diff -u llvm/lib/Support/APInt.cpp:1.79 llvm/lib/Support/APInt.cpp:1.80 --- llvm/lib/Support/APInt.cpp:1.79 Thu May 3 13:15:36 2007 +++ llvm/lib/Support/APInt.cpp Sat May 12 13:01:57 2007 @@ -1199,6 +1199,12 @@ if (shiftAmt == BitWidth) return APInt(BitWidth, 0); + // If none of the bits are shifted out, the result is *this. This avoids a + // lshr by the words size in the loop below which can produce incorrect + // results. It also avoids the expensive computation below for a common case. + if (shiftAmt == 0) + return *this; + // Create some space for the result. uint64_t * val = new uint64_t[getNumWords()]; _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits