experiment 1 with
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Mon, 18 Apr 2022 15:29:41 +0000 (16:29 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Mon, 18 Apr 2022 15:29:41 +0000 (16:29 +0100)
result <- RC + ~(RA * RB) + CARRY
gives wrong results

openpower/sv/bitmanip/divmnu64.c

index 2bdb5bbbba2d6f9e476b60b106355f01ace6fcae..02bef0bb5061cf86f0c88b36f6e92fa63fcad5b4 100644 (file)
@@ -107,12 +107,24 @@ again:
 
       // Multiply and subtract.
       k = 0;
+#ifdef ORIGINAL
       for (i = 0; i < n; i++) {
          p = qhat*vn[i];
          t = un[i+j] - k - (p & 0xFFFFFFFFLL);
          un[i+j] = t;
          k = (p >> 32) - (t >> 32);
       }
+#else
+      for (i = 0; i < n; i++) {
+         unsigned rhi;
+         unsigned long long sum;
+         p = ((unsigned long long)un[i+j])+ ~(qhat*vn[i]) + k;
+         rhi = (p >> 32);
+         if (((unsigned long long)k) <= 1) rhi += 1;
+         k = rhi;
+         un[i+j] = sum & 0xffffffff;
+      }
+#endif
       t = un[j+n] - k;
       un[j+n] = t;