From ea290b6acae3a820726c756a8f7de92035989e96 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Sun, 24 Apr 2022 20:27:27 +0100 Subject: [PATCH] use div/rem rather than re-calculate modulo from multiply --- openpower/sv/biginteger/divmnu64.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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; -- 2.30.2