[llvm-commits] CVS: llvm/lib/Support/APInt.cpp

Reid Spencer reid at x10sys.com
Tue Feb 20 21:45:13 PST 2007



Changes in directory llvm/lib/Support:

APInt.cpp updated: 1.27 -> 1.28
---
Log message:

Fix the carry in addition.


---
Diffs of the changes:  (+2 -2)

 APInt.cpp |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)


Index: llvm/lib/Support/APInt.cpp
diff -u llvm/lib/Support/APInt.cpp:1.27 llvm/lib/Support/APInt.cpp:1.28
--- llvm/lib/Support/APInt.cpp:1.27	Tue Feb 20 21:55:44 2007
+++ llvm/lib/Support/APInt.cpp	Tue Feb 20 23:44:56 2007
@@ -192,9 +192,9 @@
 static uint64_t add(uint64_t dest[], uint64_t x[], uint64_t y[], uint32_t len) {
   uint64_t carry = 0;
   for (uint32_t i = 0; i< len; ++i) {
-    uint64_t save = std::max(x[i],y[i]);
     dest[i] = x[i] + y[i] + carry;
-    carry = dest[i] < save ? 1 : 0;
+    uint64_t limit = std::min(x[i],y[i]);
+    carry = dest[i] < limit || (carry && dest[i] == limit);
   }
   return carry;
 }






More information about the llvm-commits mailing list