From e6b88df741ff14e5c4fc5e9bdcae967e9a93d8df Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Tue, 26 Apr 2022 15:26:22 +0100 Subject: [PATCH] big leftshift split out --- openpower/sv/biginteger/divgnu64.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) 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. -- 2.30.2