From: Luke Kenneth Casson Leighton Date: Sun, 24 Apr 2022 19:27:27 +0000 (+0100) Subject: use div/rem rather than re-calculate modulo from multiply X-Git-Tag: opf_rfc_ls005_v1~2604 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ea290b6acae3a820726c756a8f7de92035989e96;p=libreriscv.git use div/rem rather than re-calculate modulo from multiply --- diff --git a/openpower/sv/biginteger/divmnu64.c b/openpower/sv/biginteger/divmnu64.c index b6c4b52e7..52e70a116 100644 --- a/openpower/sv/biginteger/divmnu64.c +++ b/openpower/sv/biginteger/divmnu64.c @@ -98,8 +98,9 @@ int divmnu(unsigned q[], unsigned r[], const unsigned u[], const unsigned v[], k = 0; // the case of a for (j = m - 1; j >= 0; j--) { // single-digit - q[j] = (k * b + u[j]) / v[0]; // divisor here. - k = (k * b + u[j]) - q[j] * v[0]; + uint64_t dig2 = (k * b + u[j]); + q[j] = dig2 / v[0]; // divisor here. + k = dig2 % v[0]; // modulo bak into next loop } if (r != NULL) r[0] = k;