From: Luke Kenneth Casson Leighton Date: Mon, 18 Apr 2022 16:10:53 +0000 (+0100) Subject: EXPERIMENT2 in divmnu64.c to split out into two loops X-Git-Tag: opf_rfc_ls005_v1~2733 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=83d53ebda371b99b7cf8d7f65c9601b58fe65a1b;p=libreriscv.git EXPERIMENT2 in divmnu64.c to split out into two loops --- diff --git a/openpower/sv/bitmanip/divmnu64.c b/openpower/sv/bitmanip/divmnu64.c index 02bef0bb5..192fa1674 100644 --- a/openpower/sv/bitmanip/divmnu64.c +++ b/openpower/sv/bitmanip/divmnu64.c @@ -111,10 +111,11 @@ again: for (i = 0; i < n; i++) { p = qhat*vn[i]; t = un[i+j] - k - (p & 0xFFFFFFFFLL); - un[i+j] = t; + un[i+j] = (t & 0xffffffffLL); k = (p >> 32) - (t >> 32); } -#else +#endif +#ifdef EXPERIMENT1 for (i = 0; i < n; i++) { unsigned rhi; unsigned long long sum; @@ -124,6 +125,22 @@ again: k = rhi; un[i+j] = sum & 0xffffffff; } +#endif +#define EXPERIMENT2 +#ifdef EXPERIMENT2 + 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 + } #endif t = un[j+n] - k; un[j+n] = t;