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

mercurial at gmplib.org mercurial at gmplib.org
Wed Dec 28 23:41:53 UTC 2016


details:   /var/hg/gmp/rev/e99a7585d2b3
changeset: 17179:e99a7585d2b3
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Thu Dec 29 00:18:09 2016 +0100
description:
tests/mpn/t-mul.c: removed unuser rand source.

details:   /var/hg/gmp/rev/7b6bfc3ad455
changeset: 17180:7b6bfc3ad455
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Thu Dec 29 00:18:54 2016 +0100
description:
mpz/pprime_p.c: for replaced with do-while

details:   /var/hg/gmp/rev/d05b59ae1e1a
changeset: 17181:d05b59ae1e1a
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Thu Dec 29 00:19:49 2016 +0100
description:
mpn/generic/get_str.c: removed typo in a comment

details:   /var/hg/gmp/rev/e641cb865f34
changeset: 17182:e641cb865f34
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Thu Dec 29 00:22:12 2016 +0100
description:
mpn/generic/divrem.c: Careful use of mpn_tdiv_qr to save an allocation.

details:   /var/hg/gmp/rev/0b0959bd6251
changeset: 17183:0b0959bd6251
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Thu Dec 29 00:23:06 2016 +0100
description:
mpn/generic/toom_interpolate_8pts.c: Use _nc to propagate a carry

details:   /var/hg/gmp/rev/14b23b2900fa
changeset: 17184:14b23b2900fa
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Thu Dec 29 00:23:50 2016 +0100
description:
mpn/generic/sqrlo_basecase.c: possibly remove unoused baranches at compile-time

details:   /var/hg/gmp/rev/8ef3b6550030
changeset: 17185:8ef3b6550030
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Thu Dec 29 00:24:43 2016 +0100
description:
mpn/generic/powlo.c: Remove an element in the table

details:   /var/hg/gmp/rev/de54e46e09d0
changeset: 17186:de54e46e09d0
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Thu Dec 29 00:25:53 2016 +0100
description:
Makefile.am: Keep track of so.numbers

details:   /var/hg/gmp/rev/3d2804d8c213
changeset: 17187:3d2804d8c213
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Thu Dec 29 00:27:11 2016 +0100
description:
gmp-h.in: Use ~ __GMP_CAST (mp_bitcnt_t, 0) for maximal bit count

details:   /var/hg/gmp/rev/e81891b26c17
changeset: 17188:e81891b26c17
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Thu Dec 29 00:32:15 2016 +0100
description:
mpz/xor.c: reorder branches

details:   /var/hg/gmp/rev/8f8c547b982a
changeset: 17189:8f8c547b982a
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Thu Dec 29 00:34:23 2016 +0100
description:
Remove warnings.

details:   /var/hg/gmp/rev/51923e8b20ea
changeset: 17190:51923e8b20ea
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Thu Dec 29 00:35:15 2016 +0100
description:
gen-trialdivtab.c: Generate power of 2 with setbit

details:   /var/hg/gmp/rev/018aa791e30e
changeset: 17191:018aa791e30e
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Thu Dec 29 00:36:26 2016 +0100
description:
bootstrap.c: Generate power of 2 with setbit

details:   /var/hg/gmp/rev/2ab7a7f07ac0
changeset: 17192:2ab7a7f07ac0
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Thu Dec 29 00:37:21 2016 +0100
description:
gen-bases.c: Generate power of 2 with setbit

details:   /var/hg/gmp/rev/bc1f3c6a749d
changeset: 17193:bc1f3c6a749d
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Thu Dec 29 00:41:34 2016 +0100
description:
mpz/gcd.c: Reorder branches

diffstat:

 Makefile.am                         |   2 ++
 bootstrap.c                         |   4 ++--
 gen-bases.c                         |   8 ++++----
 gen-trialdivtab.c                   |   9 +++++----
 gmp-h.in                            |   2 +-
 mini-gmp/tests/t-sqrt.c             |   2 +-
 mpn/generic/divrem.c                |  14 +++++---------
 mpn/generic/get_str.c               |   4 ++--
 mpn/generic/powlo.c                 |  18 +++++++++---------
 mpn/generic/sqrlo_basecase.c        |  16 +++++++++++++++-
 mpn/generic/toom_interpolate_8pts.c |  12 ++++++------
 mpq/cmp.c                           |   2 +-
 mpz/gcd.c                           |  32 +++++++++++++++-----------------
 mpz/pprime_p.c                      |   7 ++++---
 mpz/xor.c                           |  34 ++++++++++++++++++----------------
 tests/mpn/t-mul.c                   |   3 ---
 16 files changed, 90 insertions(+), 79 deletions(-)

diffs (truncated from 422 to 300 lines):

diff -r 668d5f284a44 -r bc1f3c6a749d Makefile.am
--- a/Makefile.am	Wed Dec 28 18:39:40 2016 +0100
+++ b/Makefile.am	Thu Dec 29 00:41:34 2016 +0100
@@ -87,6 +87,8 @@
 #        5.1.2   11:2:1    7:2:3     -
 #        6.0.0   12:0:2    8:0:4     -
 #        6.1.0   13:0:3    9:0:5     -
+#        6.1.1   13:1:3    9:1:5     -
+#        6.1.2   13:2:3    9:2:5     -
 #
 # Starting at 3:0:0 is a slight abuse of the versioning system, but it
 # ensures we're past soname libgmp.so.2, which was used on Debian GNU/Linux
diff -r 668d5f284a44 -r bc1f3c6a749d bootstrap.c
--- a/bootstrap.c	Wed Dec 28 18:39:40 2016 +0100
+++ b/bootstrap.c	Thu Dec 29 00:41:34 2016 +0100
@@ -96,8 +96,8 @@
 
   norm = numb_bits - mpz_sizeinbase (d, 2);
   assert (norm >= 0);
-  mpz_init_set_ui (t, 1L);
-  mpz_mul_2exp (t, t, 2*numb_bits - norm);
+  mpz_init (t);
+  mpz_setbit (t, 2*numb_bits - norm);
   mpz_tdiv_q (inv, t, d);
   mpz_clrbit (inv, numb_bits);
 
diff -r 668d5f284a44 -r bc1f3c6a749d gen-bases.c
--- a/gen-bases.c	Wed Dec 28 18:39:40 2016 +0100
+++ b/gen-bases.c	Thu Dec 29 00:41:34 2016 +0100
@@ -109,13 +109,13 @@
   mpz_t t, t2, two, b;
   int i;
 
-  mpz_init_set_ui (t, 1);
-  mpz_mul_2exp (t, t, prec+EXTRA);
+  mpz_init (t);
+  mpz_setbit (t, prec + EXTRA);
 
   mpz_init (t2);
 
-  mpz_init_set_ui (two, 2);
-  mpz_mul_2exp (two, two, prec+EXTRA);
+  mpz_init (two);
+  mpz_setbit (two, prec + EXTRA + 1);
 
   mpz_set_ui (r, 0);
 
diff -r 668d5f284a44 -r bc1f3c6a749d gen-trialdivtab.c
--- a/gen-trialdivtab.c	Wed Dec 28 18:39:40 2016 +0100
+++ b/gen-trialdivtab.c	Thu Dec 29 00:41:34 2016 +0100
@@ -91,15 +91,16 @@
   for (i = 0; i < 7; i++)
     mpz_init (pre[i]);
 
-  mpz_init_set_ui (gmp_numb_max, 1);
-  mpz_mul_2exp (gmp_numb_max, gmp_numb_max, limb_bits);
+  mpz_init (B);
+  mpz_setbit (B, limb_bits);
+  mpz_init_set (gmp_numb_max, B);
   mpz_sub_ui (gmp_numb_max, gmp_numb_max, 1);
 
   mpz_init (tmp);
   mpz_init (inv);
 
-  mpz_init_set_ui (B, 1);  mpz_mul_2exp (B, B, limb_bits);
-  mpz_init_set_ui (Bhalf, 1);  mpz_mul_2exp (Bhalf, Bhalf, limb_bits - 1);
+  mpz_init (Bhalf);
+  mpz_setbit (Bhalf, limb_bits - 1);
 
   start_p = 3;
 
diff -r 668d5f284a44 -r bc1f3c6a749d gmp-h.in
--- a/gmp-h.in	Wed Dec 28 18:39:40 2016 +0100
+++ b/gmp-h.in	Thu Dec 29 00:41:34 2016 +0100
@@ -1844,7 +1844,7 @@
   mp_bitcnt_t    __gmp_result;
 
   __gmp_usize = __gmp_u->_mp_size;
-  __gmp_result = (__gmp_usize < 0 ? ULONG_MAX : 0);
+  __gmp_result = (__gmp_usize < 0 ? ~ __GMP_CAST (mp_bitcnt_t, 0) : __GMP_CAST (mp_bitcnt_t, 0));
   if (__GMP_LIKELY (__gmp_usize > 0))
     __gmp_result =  mpn_popcount (__gmp_u->_mp_d, __gmp_usize);
   return __gmp_result;
diff -r 668d5f284a44 -r bc1f3c6a749d mini-gmp/tests/t-sqrt.c
--- a/mini-gmp/tests/t-sqrt.c	Wed Dec 28 18:39:40 2016 +0100
+++ b/mini-gmp/tests/t-sqrt.c	Thu Dec 29 00:41:34 2016 +0100
@@ -87,7 +87,7 @@
     }
   } else {
     mpz_limbs_finish (r, ret);
-    if (ret != mpz_size (r)) {
+    if ((size_t) ret != mpz_size (r)) {
       fprintf (stderr, "mpn_sqrtrem wrong return value.\n");
       abort ();
     }
diff -r 668d5f284a44 -r bc1f3c6a749d mpn/generic/divrem.c
--- a/mpn/generic/divrem.c	Wed Dec 28 18:39:40 2016 +0100
+++ b/mpn/generic/divrem.c	Thu Dec 29 00:41:34 2016 +0100
@@ -71,7 +71,7 @@
     }
   else
     {
-      mp_ptr rp, q2p;
+      mp_ptr q2p;
       mp_limb_t qhl;
       mp_size_t qn;
       TMP_DECL;
@@ -80,13 +80,11 @@
       if (UNLIKELY (qxn != 0))
 	{
 	  mp_ptr n2p;
-	  n2p = TMP_ALLOC_LIMBS (nn + qxn);
+	  TMP_ALLOC_LIMBS_2 (n2p, nn + qxn,
+			     q2p, nn - dn + qxn + 1);
 	  MPN_ZERO (n2p, qxn);
 	  MPN_COPY (n2p + qxn, np, nn);
-	  q2p = TMP_ALLOC_LIMBS (nn - dn + qxn + 1);
-	  rp = TMP_ALLOC_LIMBS (dn);
-	  mpn_tdiv_qr (q2p, rp, 0L, n2p, nn + qxn, dp, dn);
-	  MPN_COPY (np, rp, dn);
+	  mpn_tdiv_qr (q2p, np, 0L, n2p, nn + qxn, dp, dn);
 	  qn = nn - dn + qxn;
 	  MPN_COPY (qp, q2p, qn);
 	  qhl = q2p[qn];
@@ -94,9 +92,7 @@
       else
 	{
 	  q2p = TMP_ALLOC_LIMBS (nn - dn + 1);
-	  rp = TMP_ALLOC_LIMBS (dn);
-	  mpn_tdiv_qr (q2p, rp, 0L, np, nn, dp, dn);
-	  MPN_COPY (np, rp, dn);	/* overwrite np area with remainder */
+	  mpn_tdiv_qr (q2p, np, 0L, np, nn, dp, dn);
 	  qn = nn - dn;
 	  MPN_COPY (qp, q2p, qn);
 	  qhl = q2p[qn];
diff -r 668d5f284a44 -r bc1f3c6a749d mpn/generic/get_str.c
--- a/mpn/generic/get_str.c	Wed Dec 28 18:39:40 2016 +0100
+++ b/mpn/generic/get_str.c	Thu Dec 29 00:41:34 2016 +0100
@@ -107,8 +107,8 @@
 
 
   The reason for the two threshold values is the cost of
-  precompute_power_tables.  GET_STR_PRECOMPUTE_THRESHOLD will be considerably
-  larger than GET_STR_PRECOMPUTE_THRESHOLD.  */
+  precompute_power_tables.  GET_STR_PRECOMPUTE_THRESHOLD will be
+  considerably larger than GET_STR_DC_THRESHOLD.  */
 
 
 /* The x86s and m68020 have a quotient and remainder "div" instruction and
diff -r 668d5f284a44 -r bc1f3c6a749d mpn/generic/powlo.c
--- a/mpn/generic/powlo.c	Wed Dec 28 18:39:40 2016 +0100
+++ b/mpn/generic/powlo.c	Thu Dec 29 00:41:34 2016 +0100
@@ -37,9 +37,9 @@
   ((p[(bi - 1) / GMP_LIMB_BITS] >> (bi - 1) % GMP_LIMB_BITS) & 1)
 
 static inline mp_limb_t
-getbits (const mp_limb_t *p, mp_bitcnt_t bi, int nbits)
+getbits (const mp_limb_t *p, mp_bitcnt_t bi, unsigned nbits)
 {
-  int nbits_in_r;
+  unsigned nbits_in_r;
   mp_limb_t r;
   mp_size_t i;
 
@@ -60,15 +60,15 @@
     }
 }
 
-static inline int
+static inline unsigned
 win_size (mp_bitcnt_t eb)
 {
-  int k;
-  static mp_bitcnt_t x[] = {1,7,25,81,241,673,1793,4609,11521,28161,~(mp_bitcnt_t)0};
+  unsigned k;
+  static mp_bitcnt_t x[] = {7,25,81,241,673,1793,4609,11521,28161,~(mp_bitcnt_t)0};
   ASSERT (eb > 1);
-  for (k = 1; eb > x[k]; ++k)
+  for (k = 0; eb > x[k]; ++k)
     ;
-  return k;
+  return k + 1;
 }
 
 /* rp[n-1..0] = bp[n-1..0] ^ ep[en-1..0] mod B^n, B is the limb base.
@@ -81,9 +81,9 @@
 	   mp_srcptr ep, mp_size_t en,
 	   mp_size_t n, mp_ptr tp)
 {
-  int cnt;
+  unsigned cnt;
   mp_bitcnt_t ebi;
-  int windowsize, this_windowsize;
+  unsigned windowsize, this_windowsize;
   mp_limb_t expbits;
   mp_limb_t *pp, *this_pp, *last_pp;
   long i;
diff -r 668d5f284a44 -r bc1f3c6a749d mpn/generic/sqrlo_basecase.c
--- a/mpn/generic/sqrlo_basecase.c	Wed Dec 28 18:39:40 2016 +0100
+++ b/mpn/generic/sqrlo_basecase.c	Thu Dec 29 00:41:34 2016 +0100
@@ -98,6 +98,14 @@
 #ifndef SQRLO_SPECIAL_CASES
 #define SQRLO_SPECIAL_CASES 2
 #endif
+
+#if TUNE_PROGRAM_BUILD || WANT_FAT_BINARY
+#define MAYBE_special_cases 1
+#else
+#define MAYBE_special_cases \
+  ((SQRLO_BASECASE_THRESHOLD <= SQRLO_SPECIAL_CASES) && (SQRLO_DC_THRESHOLD != 0))
+#endif
+
 void
 mpn_sqrlo_basecase (mp_ptr rp, mp_srcptr up, mp_size_t n)
 {
@@ -108,7 +116,7 @@
 
   ul = up[0];
 
-  if (n <= SQRLO_SPECIAL_CASES)
+  if (MAYBE_special_cases && n <= SQRLO_SPECIAL_CASES)
     {
 #if SQRLO_SPECIAL_CASES == 1
       rp[0] = (ul * ul) & GMP_NUMB_MASK;
@@ -178,3 +186,9 @@
     }
 }
 #undef SQRLO_SPECIAL_CASES
+#undef MAYBE_special_cases
+#undef SQRLO_BASECASE_ALLOC
+#undef SQRLO_SHORTCUT_MULTIPLICATIONS
+#undef MPN_SQR_DIAGONAL
+#undef MPN_SQRLO_DIAGONAL
+#undef MPN_SQRLO_DIAG_ADDLSH1
diff -r 668d5f284a44 -r bc1f3c6a749d mpn/generic/toom_interpolate_8pts.c
--- a/mpn/generic/toom_interpolate_8pts.c	Wed Dec 28 18:39:40 2016 +0100
+++ b/mpn/generic/toom_interpolate_8pts.c	Thu Dec 29 00:41:34 2016 +0100
@@ -183,12 +183,12 @@
 
   cy = mpn_add_n (pp + n, pp + n, r7, n); /* Hr8+Lr7-Lr5 */
   cy-= mpn_sub_n (pp + n, pp + n, r5, n);
-  if (0 > cy)
-    MPN_DECR_U (r7 + n, 2*n + 1, 1);
-  else
-    MPN_INCR_U (r7 + n, 2*n + 1, cy);
-
-  cy = mpn_sub_n (pp + 2*n, r7 + n, r5 + n, n); /* Mr7-Mr5 */
+  if (cy > 0) {
+    MPN_INCR_U (r7 + n, 2*n + 1, 1);
+    cy = 0;
+  }
+    
+  cy = mpn_sub_nc (pp + 2*n, r7 + n, r5 + n, n, -cy); /* Mr7-Mr5 */
   MPN_DECR_U (r7 + 2*n, n + 1, cy);
 
   cy = mpn_add_n (pp + 3*n, r5, r7+ 2*n, n+1); /* Hr7+Lr5 */
diff -r 668d5f284a44 -r bc1f3c6a749d mpq/cmp.c
--- a/mpq/cmp.c	Wed Dec 28 18:39:40 2016 +0100
+++ b/mpq/cmp.c	Thu Dec 29 00:41:34 2016 +0100
@@ -65,7 +65,7 @@
   d1h = PTR(DEN(op1))[den1_size - 1];
   d2h = PTR(den_op2)[den2_size - 1];
   op2_is_int = (den2_size | d2h) == 1;
-  if (op2_is_int == (den1_size | d1h)) /* Both ops are integers */
+  if ((unsigned) op2_is_int == (den1_size | d1h)) /* Both ops are integers */
     /* return mpz_cmp (NUM (op1), num_op2); */
     {
       int cmp;
diff -r 668d5f284a44 -r bc1f3c6a749d mpz/gcd.c
--- a/mpz/gcd.c	Wed Dec 28 18:39:40 2016 +0100
+++ b/mpz/gcd.c	Thu Dec 29 00:41:34 2016 +0100
@@ -89,12 +89,12 @@
   TMP_MARK;
 
   /*  Eliminate low zero bits from U and V and move to temporary storage.  */
-  while (*up == 0)
-    up++;
-  u_zero_limbs = up - PTR(u);
+  tp = up;
+  while (*tp == 0)
+    tp++;
+  u_zero_limbs = tp - up;
   usize -= u_zero_limbs;
-  count_trailing_zeros (u_zero_bits, *up);
-  tp = up;
+  count_trailing_zeros (u_zero_bits, *tp);
   up = TMP_ALLOC_LIMBS (usize);
   if (u_zero_bits != 0)
     {
@@ -104,12 +104,12 @@
   else
     MPN_COPY (up, tp, usize);
 
-  while (*vp == 0)
-    vp++;
-  v_zero_limbs = vp - PTR (v);
+  tp = vp;
+  while (*tp == 0)
+    tp++;
+  v_zero_limbs = tp - vp;


More information about the gmp-commit mailing list