From: Luke Kenneth Casson Leighton Date: Mon, 18 Apr 2022 16:42:41 +0000 (+0100) Subject: trying to get EXPERIMENT1 working X-Git-Tag: opf_rfc_ls005_v1~2732 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3fb634270f740460f35082544885127e29984cc4;p=libreriscv.git trying to get EXPERIMENT1 working --- diff --git a/openpower/sv/bitmanip/divmnu64.c b/openpower/sv/bitmanip/divmnu64.c index 192fa1674..52663f755 100644 --- a/openpower/sv/bitmanip/divmnu64.c +++ b/openpower/sv/bitmanip/divmnu64.c @@ -114,20 +114,32 @@ again: un[i+j] = (t & 0xffffffffLL); 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; i++) { + for (i = 0; i < n+1; i++) { unsigned rhi; unsigned long long sum; - p = ((unsigned long long)un[i+j])+ ~(qhat*vn[i]) + k; - rhi = (p >> 32); + 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 +//#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 @@ -141,9 +153,9 @@ again: un[i+j] = (t & 0xffffffffLL); k = phi[i] - (t >> 32); // take top-halves for new carry } -#endif t = un[j+n] - k; un[j+n] = t; +#endif q[j] = qhat; // Store quotient digit. if (t < 0) { // If we subtracted too