From: Luke Kenneth Casson Leighton Date: Tue, 26 Apr 2022 14:18:08 +0000 (+0100) Subject: split out bigshift X-Git-Tag: opf_rfc_ls005_v1~2582 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c771730420ffc9a670ec81dbad0fc6e141c5ae60;p=libreriscv.git split out bigshift --- diff --git a/openpower/sv/biginteger/divgnu64.c b/openpower/sv/biginteger/divgnu64.c index 6a94c66ca..483f099a5 100644 --- a/openpower/sv/biginteger/divgnu64.c +++ b/openpower/sv/biginteger/divgnu64.c @@ -56,6 +56,13 @@ void dumpit(char *msg, int n, unsigned v[]) printf("\n"); } +void bigrsh(unsigned s, unsigned r[], unsigned un[], int n) +{ + for (int i = 0; i < n - 1; i++) + r[i] = (un[i] >> s) | ((unsigned long long)un[i + 1] << (32 - s)); + r[n - 1] = un[n - 1] >> s; +} + bool bigmul(unsigned long long qhat, unsigned product[], unsigned vn[], int m, int n) { @@ -210,9 +217,7 @@ int divmnu(unsigned q[], unsigned r[], const unsigned u[], const unsigned v[], // it and pass it back. if (r != NULL) { - for (i = 0; i < n - 1; i++) - r[i] = (un[i] >> s) | ((unsigned long long)un[i + 1] << (32 - s)); - r[n - 1] = un[n - 1] >> s; + bigrsh(s, r, un, n); } return 0; }