summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/APInt.cpp
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@gmail.com>2017-05-13 07:14:17 +0000
committerCraig Topper <craig.topper@gmail.com>2017-05-13 07:14:17 +0000
commit2c9a70661c1e5eebca70b9ff6b2b38748962d79a (patch)
tree68886de87382a4d286ab78b7a0d79d55d07c717f /llvm/lib/Support/APInt.cpp
parent935f7b050fc38bdc55f50dc05039f5d2deac43b9 (diff)
downloadbcm5719-llvm-2c9a70661c1e5eebca70b9ff6b2b38748962d79a.tar.gz
bcm5719-llvm-2c9a70661c1e5eebca70b9ff6b2b38748962d79a.zip
[APInt] Use Lo_32/Hi_32/Make_64 in a few more places in the divide code. NFCI
llvm-svn: 302983
Diffstat (limited to 'llvm/lib/Support/APInt.cpp')
-rw-r--r--llvm/lib/Support/APInt.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/llvm/lib/Support/APInt.cpp b/llvm/lib/Support/APInt.cpp
index 7a1598a401e..ed6756f6ef3 100644
--- a/llvm/lib/Support/APInt.cpp
+++ b/llvm/lib/Support/APInt.cpp
@@ -1306,7 +1306,7 @@ static void KnuthDiv(uint32_t *u, uint32_t *v, uint32_t *q, uint32_t* r,
// on v[n-2] determines at high speed most of the cases in which the trial
// value qp is one too large, and it eliminates all cases where qp is two
// too large.
- uint64_t dividend = ((uint64_t(u[j+n]) << 32) + u[j+n-1]);
+ uint64_t dividend = Make_64(u[j+n], u[j+n-1]);
DEBUG(dbgs() << "KnuthDiv: dividend == " << dividend << '\n');
uint64_t qp = dividend / v[n-1];
uint64_t rp = dividend % v[n-1];
@@ -1329,14 +1329,14 @@ static void KnuthDiv(uint32_t *u, uint32_t *v, uint32_t *q, uint32_t* r,
int64_t borrow = 0;
for (unsigned i = 0; i < n; ++i) {
uint64_t p = uint64_t(qp) * uint64_t(v[i]);
- int64_t subres = int64_t(u[j+i]) - borrow - (unsigned)p;
- u[j+i] = (unsigned)subres;
- borrow = (p >> 32) - (subres >> 32);
+ int64_t subres = int64_t(u[j+i]) - borrow - Lo_32(p);
+ u[j+i] = Lo_32(subres);
+ borrow = Hi_32(p) - Hi_32(subres);
DEBUG(dbgs() << "KnuthDiv: u[j+i] = " << u[j+i]
<< ", borrow = " << borrow << '\n');
}
bool isNeg = u[j+n] < borrow;
- u[j+n] -= (unsigned)borrow;
+ u[j+n] -= Lo_32(borrow);
DEBUG(dbgs() << "KnuthDiv: after subtraction:");
DEBUG(for (int i = m+n; i >=0; i--) dbgs() << " " << u[i]);
@@ -1344,7 +1344,7 @@ static void KnuthDiv(uint32_t *u, uint32_t *v, uint32_t *q, uint32_t* r,
// D5. [Test remainder.] Set q[j] = qp. If the result of step D4 was
// negative, go to step D6; otherwise go on to step D7.
- q[j] = (unsigned)qp;
+ q[j] = Lo_32(qp);
if (isNeg) {
// D6. [Add back]. The probability that this step is necessary is very
// small, on the order of only 2/b. Make sure that test data accounts for
OpenPOWER on IntegriCloud