Likely GMP bug

Marco Bodrato bodrato at mail.dm.unipi.it
Sat May 26 21:53:15 UTC 2018


Ciao,

Il Sab, 26 Maggio 2018 11:12 pm, Niels Möller ha scritto:
> tg at gmplib.org (Torbjörn Granlund) writes:
>
>> I think we should rewrite relevant parts and avoid these constructs.

> It would help clarity if we could reduce number of variants. If we
> delete the unused USE_ZEROTAB code and the unused (?) GCD_1_METHOD == 1
> versions, it would be easier to reorganize loop entry.

Or we can simply "strip U maybe" before entering the loop.

I suggest:

diff -r a2b594f11916 mpn/generic/gcd_1.c
--- a/mpn/generic/gcd_1.c       Sun May 13 16:13:42 2018 +0200
+++ b/mpn/generic/gcd_1.c       Sat May 26 23:50:42 2018 +0200
@@ -105,7 +105,10 @@
       ulimb %= vlimb;
       if (ulimb == 0)
        goto done;
-      goto strip_u_maybe;
+
+    strip_u_maybe:
+      count_trailing_zeros (u_low_zero_bits, ulimb);
+      ulimb >>= u_low_zero_bits;
     }

   ASSERT (ulimb & 1);
@@ -124,8 +127,6 @@
            {
              ulimb >>= 1;
              ASSERT (ulimb != 0);
-           strip_u_maybe:
-             ;
            }
          while ((ulimb & 1) == 0);
        }
@@ -169,19 +170,10 @@
       while (UNLIKELY (c == MAXSHIFT))
        {
          ulimb >>= MAXSHIFT;
-         if (0)
-         strip_u_maybe:
-           vlimb >>= 1;

          c = zerotab[ulimb & MASK];
        }
 #else
-      if (0)
-       {
-       strip_u_maybe:
-         vlimb >>= 1;
-         t = ulimb;
-       }
       count_trailing_zeros (c, t);
 #endif
       ulimb >>= (c + 1);




Ĝis,
m

-- 
http://bodrato.it/



More information about the gmp-bugs mailing list