From: Luke Kenneth Casson Leighton Date: Tue, 26 Apr 2022 14:26:22 +0000 (+0100) Subject: big leftshift split out X-Git-Tag: opf_rfc_ls005_v1~2581 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e6b88df741ff14e5c4fc5e9bdcae967e9a93d8df;p=libreriscv.git big leftshift split out --- diff --git a/openpower/sv/biginteger/divgnu64.c b/openpower/sv/biginteger/divgnu64.c index 483f099a5..18e765e6d 100644 --- a/openpower/sv/biginteger/divgnu64.c +++ b/openpower/sv/biginteger/divgnu64.c @@ -63,6 +63,13 @@ void bigrsh(unsigned s, unsigned r[], unsigned un[], int n) r[n - 1] = un[n - 1] >> s; } +void biglsh(unsigned s, unsigned vn[], unsigned const v[], int n) +{ + for (int i = n - 1; i > 0; i--) + vn[i] = (v[i] << s) | ((unsigned long long)v[i - 1] >> (32 - s)); + vn[0] = v[0] << s; +} + bool bigmul(unsigned long long qhat, unsigned product[], unsigned vn[], int m, int n) { @@ -177,15 +184,11 @@ int divmnu(unsigned q[], unsigned r[], const unsigned u[], const unsigned v[], s = nlz(v[n - 1]); // 0 <= s <= 31. vn = (unsigned *)alloca(4 * n); - for (i = n - 1; i > 0; i--) - vn[i] = (v[i] << s) | ((unsigned long long)v[i - 1] >> (32 - s)); - vn[0] = v[0] << s; + biglsh(s, vn, v, n); un = (unsigned *)alloca(4 * (m + 1)); un[m] = (unsigned long long)u[m - 1] >> (32 - s); - for (i = m - 1; i > 0; i--) - un[i] = (u[i] << s) | ((unsigned long long)u[i - 1] >> (32 - s)); - un[0] = u[0] << s; + biglsh(s, un, u, m); for (j = m - n; j >= 0; j--) { // Main loop.