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

Reid Spencer reid at x10sys.com
Sat Feb 17 14:38:26 PST 2007



Changes in directory llvm/lib/Support:

APInt.cpp updated: 1.15 -> 1.16
---
Log message:

Fix some bugs in division logic.


---
Diffs of the changes:  (+5 -3)

 APInt.cpp |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)


Index: llvm/lib/Support/APInt.cpp
diff -u llvm/lib/Support/APInt.cpp:1.15 llvm/lib/Support/APInt.cpp:1.16
--- llvm/lib/Support/APInt.cpp:1.15	Fri Feb 16 21:16:00 2007
+++ llvm/lib/Support/APInt.cpp	Sat Feb 17 16:38:07 2007
@@ -980,7 +980,7 @@
   unsigned carry = 0;
   unsigned j = 0;
   do {
-    uint64_t prod = ((uint64_t) x[j] & 0xffffffffL) * yl;
+    uint64_t prod = ((uint64_t) x[j] & 0xffffffffUL) * yl;
     unsigned prod_low = (unsigned) prod;
     unsigned prod_high = (unsigned) (prod >> 32);
     prod_low += carry;
@@ -1104,7 +1104,8 @@
       X = APIntOps::shl(Result, nshift);
       ++lhsWords;
     }
-    div((unsigned*)X.pVal, lhsWords * 2 - 1, (unsigned*)Y.pVal, rhsWords*2);
+    div((unsigned*)X.pVal, lhsWords * 2 - 1, 
+        (unsigned*)(Y.isSingleWord()? &Y.VAL : Y.pVal), rhsWords*2);
     memset(Result.pVal, 0, Result.getNumWords() * 8);
     memcpy(Result.pVal, X.pVal + rhsWords, (lhsWords - rhsWords) * 8);
   }
@@ -1154,7 +1155,8 @@
       APIntOps::shl(Y, nshift);
       APIntOps::shl(X, nshift);
     }
-    div((unsigned*)X.pVal, rhsWords*2-1, (unsigned*)Y.pVal, rhsWords*2);
+    div((unsigned*)X.pVal, rhsWords*2-1, 
+        (unsigned*)(Y.isSingleWord()? &Y.VAL : Y.pVal), rhsWords*2);
     memset(Result.pVal, 0, Result.getNumWords() * 8);
     for (unsigned i = 0; i < rhsWords-1; ++i)
       Result.pVal[i] = (X.pVal[i] >> nshift) | (X.pVal[i+1] << (64 - nshift));






More information about the llvm-commits mailing list