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

mercurial at gmplib.org mercurial at gmplib.org
Thu Oct 29 06:43:11 UTC 2020


details:   /var/hg/gmp/rev/f9a421d24202
changeset: 18117:f9a421d24202
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Thu Oct 29 07:41:01 2020 +0100
description:
mpz/aors_ui.h: REALLOC with extra limb only when needed.

details:   /var/hg/gmp/rev/ffe75fedead7
changeset: 18118:ffe75fedead7
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Thu Oct 29 07:42:04 2020 +0100
description:
limb_apprsqrt: Slightly faster formula

details:   /var/hg/gmp/rev/3ef2ff534184
changeset: 18119:3ef2ff534184
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Thu Oct 29 07:42:30 2020 +0100
description:
ChangeLog

details:   /var/hg/gmp/rev/2acab08f7797
changeset: 18120:2acab08f7797
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Thu Oct 29 07:43:03 2020 +0100
description:
Copyright year

diffstat:

 ChangeLog           |   8 ++++++++
 mpz/aors_ui.h       |  21 +++++++++++++--------
 mpz/bin_uiui.c      |   4 ++--
 mpz/oddfac_1.c      |   4 ++--
 mpz/stronglucas.c   |   4 ++--
 tests/mpz/convert.c |   4 ++--
 6 files changed, 29 insertions(+), 16 deletions(-)

diffs (138 lines):

diff -r c08fc9ee081d -r 2acab08f7797 ChangeLog
--- a/ChangeLog	Mon Oct 26 19:47:10 2020 +0100
+++ b/ChangeLog	Thu Oct 29 07:43:03 2020 +0100
@@ -1,3 +1,11 @@
+2020-10-29 Marco Bodrato <bodrato at mail.dm.unipi.it>
+
+	* mpz/aors_ui.h: REALLOC with extra limb only when needed.
+
+	* mpz/bin_uiui.c (limb_apprsqrt): Slightly faster formula.
+	* mpz/oddfac_1.c (limb_apprsqrt): Likewise.
+	* mpz/stronglucas.c (limb_apprsqrt): Likewise.
+
 2020-10-25 Marco Bodrato <bodrato at mail.dm.unipi.it>
 
 	* configfsf.guess: Updated to version 2020-10-22, from gnulib.
diff -r c08fc9ee081d -r 2acab08f7797 mpz/aors_ui.h
--- a/mpz/aors_ui.h	Mon Oct 26 19:47:10 2020 +0100
+++ b/mpz/aors_ui.h	Thu Oct 29 07:43:03 2020 +0100
@@ -1,8 +1,8 @@
 /* mpz_add_ui, mpz_sub_ui -- Add or subtract an mpz_t and an unsigned
    one-word integer.
 
-Copyright 1991, 1993, 1994, 1996, 1999-2002, 2004, 2012, 2013, 2015
-Free Software Foundation, Inc.
+Copyright 1991, 1993, 1994, 1996, 1999-2002, 2004, 2012, 2013, 2015,
+2020 Free Software Foundation, Inc.
 
 This file is part of the GNU MP Library.
 
@@ -86,21 +86,26 @@
 
   abs_usize = ABS (usize);
 
-  /* If not space for W (and possible carry), increase space.  */
-  wp = MPZ_REALLOC (w, abs_usize + 1);
-
-  /* These must be after realloc (U may be the same as W).  */
-  up = PTR (u);
-
   if (usize VARIATION_CMP 0)
     {
       mp_limb_t cy;
+
+      /* If not space for W (and possible carry), increase space.  */
+      wp = MPZ_REALLOC (w, abs_usize + 1);
+      /* These must be after realloc (U may be the same as W).  */
+      up = PTR (u);
+
       cy = mpn_add_1 (wp, up, abs_usize, (mp_limb_t) vval);
       wp[abs_usize] = cy;
       wsize = VARIATION_NEG (abs_usize + cy);
     }
   else
     {
+      /* If not space for W, increase space.  */
+      wp = MPZ_REALLOC (w, abs_usize);
+      /* These must be after realloc (U may be the same as W).  */
+      up = PTR (u);
+
       /* The signs are different.  Need exact comparison to determine
 	 which operand to subtract from which.  */
       if (abs_usize == 1 && up[0] < vval)
diff -r c08fc9ee081d -r 2acab08f7797 mpz/bin_uiui.c
--- a/mpz/bin_uiui.c	Mon Oct 26 19:47:10 2020 +0100
+++ b/mpz/bin_uiui.c	Thu Oct 29 07:43:03 2020 +0100
@@ -2,7 +2,7 @@
 
 Contributed to the GNU project by Torbjorn Granlund and Marco Bodrato.
 
-Copyright 2010-2012, 2015-2018 Free Software Foundation, Inc.
+Copyright 2010-2012, 2015-2018, 2020 Free Software Foundation, Inc.
 
 This file is part of the GNU MP Library.
 
@@ -584,7 +584,7 @@
   ASSERT (x > 2);
   count_leading_zeros (s, x);
   s = (GMP_LIMB_BITS - s) >> 1;
-  return ((CNST_LIMB(1) << s) + (x >> s)) >> 1;
+  return ((CNST_LIMB(1) << (s - 1)) + (x >> 1 >> s));
 }
 
 static void
diff -r c08fc9ee081d -r 2acab08f7797 mpz/oddfac_1.c
--- a/mpz/oddfac_1.c	Mon Oct 26 19:47:10 2020 +0100
+++ b/mpz/oddfac_1.c	Thu Oct 29 07:43:03 2020 +0100
@@ -7,7 +7,7 @@
 IN FACT, IT IS ALMOST GUARANTEED THAT IT WILL CHANGE OR
 DISAPPEAR IN A FUTURE GNU MP RELEASE.
 
-Copyright 2010-2012, 2015-2017 Free Software Foundation, Inc.
+Copyright 2010-2012, 2015-2017, 2020 Free Software Foundation, Inc.
 
 This file is part of the GNU MP Library.
 
@@ -132,7 +132,7 @@
   ASSERT (x > 2);
   count_leading_zeros (s, x);
   s = (GMP_LIMB_BITS - s) >> 1;
-  return ((CNST_LIMB(1) << s) + (x >> s)) >> 1;
+  return ((CNST_LIMB(1) << (s - 1)) + (x >> 1 >> s));
 }
 
 #if 0
diff -r c08fc9ee081d -r 2acab08f7797 mpz/stronglucas.c
--- a/mpz/stronglucas.c	Mon Oct 26 19:47:10 2020 +0100
+++ b/mpz/stronglucas.c	Thu Oct 29 07:43:03 2020 +0100
@@ -5,7 +5,7 @@
    CERTAIN TO BE SUBJECT TO INCOMPATIBLE CHANGES OR DISAPPEAR COMPLETELY IN
    FUTURE GNU MP RELEASES.
 
-Copyright 2018 Free Software Foundation, Inc.
+Copyright 2018, 2020 Free Software Foundation, Inc.
 
 Contributed by Marco Bodrato.
 
@@ -52,7 +52,7 @@
   ASSERT (x > 2);
   count_leading_zeros (s, x);
   s = (GMP_LIMB_BITS - s) >> 1;
-  return ((CNST_LIMB(1) << s) + (x >> s)) >> 1;
+  return ((CNST_LIMB(1) << (s - 1)) + (x >> 1 >> s));
 }
 
 static int
diff -r c08fc9ee081d -r 2acab08f7797 tests/mpz/convert.c
--- a/tests/mpz/convert.c	Mon Oct 26 19:47:10 2020 +0100
+++ b/tests/mpz/convert.c	Thu Oct 29 07:43:03 2020 +0100
@@ -1,7 +1,7 @@
 /* Test conversion using mpz_get_str and mpz_set_str.
 
-Copyright 1993, 1994, 1996, 1999-2002, 2006, 2007 Free Software Foundation,
-Inc.
+Copyright 1993, 1994, 1996, 1999-2002, 2006, 2007, 2020 Free Software
+Foundation, Inc.
 
 This file is part of the GNU MP Library test suite.
 



More information about the gmp-commit mailing list