// Multiply and subtract.
k = 0;
-#ifdef ORIGINAL
for (i = 0; i < n; i++) {
p = qhat*vn[i];
t = un[i+j] - k - (p & 0xFFFFFFFFLL);
- un[i+j] = (t & 0xffffffffLL);
+ un[i+j] = t;
k = (p >> 32) - (t >> 32);
}
t = un[j+n] - k;
un[j+n] = t;
-#endif
-#define EXPERIMENT1
- k = 1;
-#ifdef EXPERIMENT1
- for (i = 0; i < n+1; i++) {
- unsigned rhi;
- unsigned long long sum;
- if (i != n) {
- p = qhat*vn[i];
- sum = ((unsigned long long)un[i+j]) + ~p + k;
- } else { // for last loop instead of separate cleanup do special sum
- sum = (~0)+k;
- }
- rhi = (sum >> 32);
- if (((unsigned long long)k) <= 1) rhi += 1;
- k = rhi;
- un[i+j] = sum & 0xffffffff;
- }
- // XXX t is not properly computed, it must contain -ve
- // if the subtract should not have occurred
-#endif
-//#define EXPERIMENT2
-#ifdef EXPERIMENT2
- k = 0;
- unsigned long phi[200]; // yes, not malloced, we know
- unsigned long plo[200]; // yes, not malloced, we know
- // double-width multiply with strange subtract only on bottom half
- for (i = 0; i < n; i++) {
- unsigned long long p = qhat*vn[i];
- plo[i] = un[i+j] - (p&0xffffffffLL);
- phi[i] = p >> 32;
- }
- for (i = 0; i < n; i++) {
- t = plo[i] - k; // subtract previous carry
- un[i+j] = (t & 0xffffffffLL);
- k = phi[i] - (t >> 32); // take top-halves for new carry
- }
- t = un[j+n] - k;
- un[j+n] = t;
-#endif
q[j] = qhat; // Store quotient digit.
if (t < 0) { // If we subtracted too