llvm.org GIT mirror llvm / f3c348a
[APInt] Use Lo_32/Hi_32/Make_64 in a few more places in the divide code. NFCI git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302983 91177308-0d34-0410-b5e6-96231b3b80d8 Craig Topper 3 years ago
1 changed file(s) with 6 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
13051305 // on v[n-2] determines at high speed most of the cases in which the trial
13061306 // value qp is one too large, and it eliminates all cases where qp is two
13071307 // too large.
1308 uint64_t dividend = ((uint64_t(u[j+n]) << 32) + u[j+n-1]);
1308 uint64_t dividend = Make_64(u[j+n], u[j+n-1]);
13091309 DEBUG(dbgs() << "KnuthDiv: dividend == " << dividend << '\n');
13101310 uint64_t qp = dividend / v[n-1];
13111311 uint64_t rp = dividend % v[n-1];
13281328 int64_t borrow = 0;
13291329 for (unsigned i = 0; i < n; ++i) {
13301330 uint64_t p = uint64_t(qp) * uint64_t(v[i]);
1331 int64_t subres = int64_t(u[j+i]) - borrow - (unsigned)p;
1332 u[j+i] = (unsigned)subres;
1333 borrow = (p >> 32) - (subres >> 32);
1331 int64_t subres = int64_t(u[j+i]) - borrow - Lo_32(p);
1332 u[j+i] = Lo_32(subres);
1333 borrow = Hi_32(p) - Hi_32(subres);
13341334 DEBUG(dbgs() << "KnuthDiv: u[j+i] = " << u[j+i]
13351335 << ", borrow = " << borrow << '\n');
13361336 }
13371337 bool isNeg = u[j+n] < borrow;
1338 u[j+n] -= (unsigned)borrow;
1338 u[j+n] -= Lo_32(borrow);
13391339
13401340 DEBUG(dbgs() << "KnuthDiv: after subtraction:");
13411341 DEBUG(for (int i = m+n; i >=0; i--) dbgs() << " " << u[i]);
13431343
13441344 // D5. [Test remainder.] Set q[j] = qp. If the result of step D4 was
13451345 // negative, go to step D6; otherwise go on to step D7.
1346 q[j] = (unsigned)qp;
1346 q[j] = Lo_32(qp);
13471347 if (isNeg) {
13481348 // D6. [Add back]. The probability that this step is necessary is very
13491349 // small, on the order of only 2/b. Make sure that test data accounts for