use shift-and-or rather than mul-and-add in
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Mon, 25 Apr 2022 20:03:10 +0000 (21:03 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Mon, 25 Apr 2022 20:03:10 +0000 (21:03 +0100)
construction of 64-bit from 2x32-bit

openpower/sv/biginteger/divmnu64.c

index 52e70a116f25af1f4f345a4cc316676f50f24e2c..c77d9b780a929aba11d7a39107cc5294876709a1 100644 (file)
@@ -98,9 +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
-            uint64_t dig2 = (k * b + u[j]);
+            uint64_t dig2 = (k << 32 ) | u[j];
             q[j] = dig2 / v[0]; // divisor here.
-            k = dig2 % v[0]; // modulo bak into next loop
+            k    = dig2 % v[0]; // modulo back into next loop
         }
         if (r != NULL)
             r[0] = k;