From: Luke Kenneth Casson Leighton Date: Tue, 26 Apr 2022 15:00:46 +0000 (+0100) Subject: whitespace X-Git-Tag: opf_rfc_ls005_v1~2580 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=452bee068ee8a06a75092d25e69a65f0c09cdfaf;p=libreriscv.git whitespace --- diff --git a/openpower/sv/biginteger/divgnu64.c b/openpower/sv/biginteger/divgnu64.c index 18e765e6d..3c216eff8 100644 --- a/openpower/sv/biginteger/divgnu64.c +++ b/openpower/sv/biginteger/divgnu64.c @@ -165,11 +165,9 @@ int divmnu(unsigned q[], unsigned r[], const unsigned u[], const unsigned v[], if (m < n || n <= 0 || v[n - 1] == 0) return 1; // Return if invalid param. - if (n == 1) - { // Take care of + if (n == 1) { // Take care of k = 0; // the case of a - for (j = m - 1; j >= 0; j--) - { // single-digit + 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]; } @@ -183,23 +181,22 @@ int divmnu(unsigned q[], unsigned r[], const unsigned u[], const unsigned v[], high-order digit on the dividend; we do that unconditionally. */ s = nlz(v[n - 1]); // 0 <= s <= 31. + vn = (unsigned *)alloca(4 * n); biglsh(s, vn, v, n); un = (unsigned *)alloca(4 * (m + 1)); - un[m] = (unsigned long long)u[m - 1] >> (32 - s); + un[m] = (unsigned long long)u[m - 1] >> (32 - s); // extra digit biglsh(s, un, u, m); - for (j = m - n; j >= 0; j--) - { // Main loop. + for (j = m - n; j >= 0; j--) { // Main loop. // Compute estimate qhat of q[j] from top 2 digits uint64_t dig2 = ((uint64_t)un[j + n] << 32) | un[j + n - 1]; qhat = dig2 / vn[n - 1]; rhat = dig2 % vn[n - 1]; again: // use 3rd-from-top digit to obtain better accuracy - if (qhat >= b || qhat * vn[n - 2] > b * rhat + un[j + n - 2]) - { + if (qhat >= b || qhat * vn[n - 2] > b * rhat + un[j + n - 2]) { qhat = qhat - 1; rhat = rhat + vn[n - 1]; if (rhat < b) @@ -210,8 +207,7 @@ int divmnu(unsigned q[], unsigned r[], const unsigned u[], const unsigned v[], bool need_fixup = bigmulsub(qhat, vn, un_j, j, m, n); q[j] = qhat; // Store quotient digit. - if (need_fixup) - { // If we subtracted too + if (need_fixup) { // If we subtracted too q[j] = q[j] - 1; // much, add back. bigadd(un_j, vn, un_j, m, n, 0); } @@ -219,9 +215,7 @@ int divmnu(unsigned q[], unsigned r[], const unsigned u[], const unsigned v[], // If the caller wants the remainder, unnormalize // it and pass it back. if (r != NULL) - { bigrsh(s, r, un, n); - } return 0; }