[Gmp-commit] /var/hg/gmp: 4 new changesets

mercurial at gmplib.org mercurial at gmplib.org
Thu Feb 6 16:50:53 UTC 2020


details:   /var/hg/gmp/rev/29532497c499
changeset: 18033:29532497c499
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Thu Feb 06 17:32:22 2020 +0100
description:
mini-gmp/mini-gmp.c (gmp_jacobi_coprime): Change syntax for loop.

details:   /var/hg/gmp/rev/060cdca2803b
changeset: 18034:060cdca2803b
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Thu Feb 06 17:34:22 2020 +0100
description:
mpn/generic/jacbase.c (mpn_jacobi_base): Exit condition for _METHOD == 4

details:   /var/hg/gmp/rev/c3f10f1dc54b
changeset: 18035:c3f10f1dc54b
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Thu Feb 06 17:49:44 2020 +0100
description:
mpn/generic/perfsqr.c: Small changes in unused code...

details:   /var/hg/gmp/rev/b1841e762ccd
changeset: 18036:b1841e762ccd
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Thu Feb 06 17:50:10 2020 +0100
description:
mpz/aors.h: Optimize branches.

diffstat:

 mini-gmp/mini-gmp.c   |   5 ++---
 mpn/generic/jacbase.c |   4 ++--
 mpn/generic/perfsqr.c |   5 ++---
 mpz/aors.h            |  38 ++++++++++++++++++++++----------------
 4 files changed, 28 insertions(+), 24 deletions(-)

diffs (131 lines):

diff -r 2624648aa8e1 -r b1841e762ccd mini-gmp/mini-gmp.c
--- a/mini-gmp/mini-gmp.c	Sun Feb 02 16:06:52 2020 +0100
+++ b/mini-gmp/mini-gmp.c	Thu Feb 06 17:50:10 2020 +0100
@@ -2,7 +2,7 @@
 
    Contributed to the GNU project by Niels Möller
 
-Copyright 1991-1997, 1999-2019 Free Software Foundation, Inc.
+Copyright 1991-1997, 1999-2020 Free Software Foundation, Inc.
 
 This file is part of the GNU MP Library.
 
@@ -3350,7 +3350,7 @@
   gmp_ctz(c, a);
   a >>= 1;
 
-  do
+  for (;;)
     {
       a >>= c;
       /* (2/b) = -1 if b = 3 or 5 mod 8 */
@@ -3372,7 +3372,6 @@
       gmp_ctz(c, a);
       ++c;
     }
-  while (1);
 }
 
 static void
diff -r 2624648aa8e1 -r b1841e762ccd mpn/generic/jacbase.c
--- a/mpn/generic/jacbase.c	Sun Feb 02 16:06:52 2020 +0100
+++ b/mpn/generic/jacbase.c	Thu Feb 06 17:50:10 2020 +0100
@@ -3,7 +3,7 @@
    THIS INTERFACE IS PRELIMINARY AND MIGHT DISAPPEAR OR BE SUBJECT TO
    INCOMPATIBLE CHANGES IN A FUTURE RELEASE OF GMP.
 
-Copyright 1999-2002, 2010 Free Software Foundation, Inc.
+Copyright 1999-2002, 2010, 2020 Free Software Foundation, Inc.
 
 This file is part of the GNU MP Library.
 
@@ -235,7 +235,7 @@
       bit ^= c & (b ^ (b >> 1));
       a >>= c;
     }
-  while (b > 0);
+  while (a > 0);
 
   return 1-2*(bit & 1);
 }
diff -r 2624648aa8e1 -r b1841e762ccd mpn/generic/perfsqr.c
--- a/mpn/generic/perfsqr.c	Sun Feb 02 16:06:52 2020 +0100
+++ b/mpn/generic/perfsqr.c	Thu Feb 06 17:50:10 2020 +0100
@@ -194,7 +194,7 @@
 #if 0
   /* Check that we have even multiplicity of 2, and then check that the rest is
      a possible perfect square.  Leave disabled until we can determine this
-     really is an improvement.  It it is, it could completely replace the
+     really is an improvement.  If it is, it could completely replace the
      simple probe above, since this should throw out more non-squares, but at
      the expense of somewhat more cycles.  */
   {
@@ -207,8 +207,7 @@
     if ((cnt & 1) != 0)
       return 0;			/* return of not even multiplicity of 2 */
     lo >>= cnt;			/* shift down to align lowest non-zero bit */
-    lo >>= 1;			/* shift away lowest non-zero bit */
-    if ((lo & 3) != 0)
+    if ((lo & 6) != 0)
       return 0;
   }
 #endif
diff -r 2624648aa8e1 -r b1841e762ccd mpz/aors.h
--- a/mpz/aors.h	Sun Feb 02 16:06:52 2020 +0100
+++ b/mpz/aors.h	Thu Feb 06 17:50:10 2020 +0100
@@ -1,7 +1,7 @@
 /* mpz_add, mpz_sub -- add or subtract integers.
 
-Copyright 1991, 1993, 1994, 1996, 2000, 2001, 2011, 2012 Free Software
-Foundation, Inc.
+Copyright 1991, 1993, 1994, 1996, 2000, 2001, 2011, 2012, 2020 Free
+Software Foundation, Inc.
 
 This file is part of the GNU MP Library.
 
@@ -88,25 +88,31 @@
 	{
 	  mpn_sub (wp, up, abs_usize, vp, abs_vsize);
 	  wsize = abs_usize;
-	  MPN_NORMALIZE (wp, wsize);
+	  MPN_NORMALIZE_NOT_ZERO (wp, wsize);
 	  if (usize < 0)
 	    wsize = -wsize;
 	}
-      else if (mpn_cmp (up, vp, abs_usize) < 0)
-	{
-	  mpn_sub_n (wp, vp, up, abs_usize);
-	  wsize = abs_usize;
-	  MPN_NORMALIZE (wp, wsize);
-	  if (usize >= 0)
-	    wsize = -wsize;
-	}
       else
 	{
-	  mpn_sub_n (wp, up, vp, abs_usize);
-	  wsize = abs_usize;
-	  MPN_NORMALIZE (wp, wsize);
-	  if (usize < 0)
-	    wsize = -wsize;
+	  int cmp = mpn_cmp (up, vp, abs_usize);
+	  if (cmp < 0)
+	    {
+	      mpn_sub_n (wp, vp, up, abs_usize);
+	      wsize = abs_usize;
+	      MPN_NORMALIZE_NOT_ZERO (wp, wsize);
+	      if (usize >= 0)
+		wsize = -wsize;
+	    }
+	  else if (cmp > 0)
+	    {
+	      mpn_sub_n (wp, up, vp, abs_usize);
+	      wsize = abs_usize;
+	      MPN_NORMALIZE_NOT_ZERO (wp, wsize);
+	      if (usize < 0)
+		wsize = -wsize;
+	    }
+	  else
+	    wsize = 0;
 	}
     }
   else


More information about the gmp-commit mailing list