Changes in directory llvm/lib/Support:
APInt.cpp updated: 1.35 -> 1.36 --- Log message: Fix the remainder shifting in KnuthDiv. --- Diffs of the changes: (+13 -6) APInt.cpp | 19 +++++++++++++------ 1 files changed, 13 insertions(+), 6 deletions(-) Index: llvm/lib/Support/APInt.cpp diff -u llvm/lib/Support/APInt.cpp:1.35 llvm/lib/Support/APInt.cpp:1.36 --- llvm/lib/Support/APInt.cpp:1.35 Sat Feb 24 14:19:37 2007 +++ llvm/lib/Support/APInt.cpp Sat Feb 24 14:38:01 2007 @@ -1134,12 +1134,19 @@ // The value d is expressed by the "shift" value above since we avoided // multiplication by d by using a shift left. So, all we have to do is // shift right here. In order to mak - uint32_t carry = 0; - DEBUG(cerr << "KnuthDiv: remainder:"); - for (int i = n-1; i >= 0; i--) { - r[i] = (u[i] >> shift) | carry; - carry = u[i] << shift; - DEBUG(cerr << " " << r[i]); + if (shift) { + uint32_t carry = 0; + DEBUG(cerr << "KnuthDiv: remainder:"); + for (int i = n-1; i >= 0; i--) { + r[i] = (u[i] >> shift) | carry; + carry = u[i] << (32 - shift); + DEBUG(cerr << " " << r[i]); + } + } else { + for (int i = n-1; i >= 0; i--) { + r[i] = u[i]; + DEBUG(cerr << " " << r[i]); + } } DEBUG(cerr << '\n'); } _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits