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

mercurial at gmplib.org mercurial at gmplib.org
Mon Jun 16 13:46:39 UTC 2014


details:   /var/hg/gmp/rev/e18830233d2c
changeset: 16438:e18830233d2c
user:      Torbjorn Granlund <tege at gmplib.org>
date:      Mon Jun 16 10:56:40 2014 +0200
description:
(perfpow): Combine TMP_ALLOCs.

details:   /var/hg/gmp/rev/347c698bcb87
changeset: 16439:347c698bcb87
user:      Torbjorn Granlund <tege at gmplib.org>
date:      Mon Jun 16 15:43:37 2014 +0200
description:
Fix comment typo.

details:   /var/hg/gmp/rev/00cce068ad61
changeset: 16440:00cce068ad61
user:      Torbjorn Granlund <tege at gmplib.org>
date:      Mon Jun 16 15:44:28 2014 +0200
description:
ChangeLog

details:   /var/hg/gmp/rev/7d46dceebe4c
changeset: 16441:7d46dceebe4c
user:      Torbjorn Granlund <tege at gmplib.org>
date:      Mon Jun 16 15:46:27 2014 +0200
description:
Postpone TMP_MARK.

diffstat:

 ChangeLog             |   4 ++++
 mpf/mul.c             |   7 ++++---
 mpn/generic/div_q.c   |   2 +-
 mpn/generic/perfpow.c |  19 ++++++++++++-------
 4 files changed, 21 insertions(+), 11 deletions(-)

diffs (112 lines):

diff -r 4942270f8f2a -r 7d46dceebe4c ChangeLog
--- a/ChangeLog	Sun Jun 15 01:27:26 2014 +0200
+++ b/ChangeLog	Mon Jun 16 15:46:27 2014 +0200
@@ -1,3 +1,7 @@
+2014-06-16  Torbjörn Granlund  <tege at gmplib.org>
+
+	* mpn/generic/perfpow.c (perfpow): Combine TMP_ALLOCs.
+
 2014-06-15  Torbjörn Granlund  <tege at gmplib.org>
 
 	* tests/refmpn.c (refmpn_mul): Rewrite to avoid O(n) recursion depth.
diff -r 4942270f8f2a -r 7d46dceebe4c mpf/mul.c
--- a/mpf/mul.c	Sun Jun 15 01:27:26 2014 +0200
+++ b/mpf/mul.c	Mon Jun 16 15:46:27 2014 +0200
@@ -38,9 +38,7 @@
   mp_size_t usize, vsize;
   mp_size_t sign_product;
   mp_size_t prec = r->_mp_prec;
-  TMP_DECL;
 
-  TMP_MARK;
   usize = u->_mp_size;
   vsize = v->_mp_size;
   sign_product = usize ^ vsize;
@@ -72,7 +70,9 @@
       mp_limb_t cy_limb;
       mp_ptr rp, tp;
       mp_size_t adj;
+      TMP_DECL;
 
+      TMP_MARK;
       rsize = usize + vsize;
       tp = TMP_ALLOC_LIMBS (rsize);
       cy_limb = (usize >= vsize
@@ -91,6 +91,7 @@
       MPN_COPY (rp, tp, rsize);
       r->_mp_exp = u->_mp_exp + v->_mp_exp - adj;
       r->_mp_size = sign_product >= 0 ? rsize : -rsize;
+
+      TMP_FREE;
     }
-  TMP_FREE;
 }
diff -r 4942270f8f2a -r 7d46dceebe4c mpn/generic/div_q.c
--- a/mpn/generic/div_q.c	Sun Jun 15 01:27:26 2014 +0200
+++ b/mpn/generic/div_q.c	Mon Jun 16 15:46:27 2014 +0200
@@ -277,7 +277,7 @@
 	}
       else  /* divisor is already normalised */
 	{
-	  MPN_COPY (new_np, np + nn - new_nn, new_nn); /* pointless of MU will be used */
+	  MPN_COPY (new_np, np + nn - new_nn, new_nn); /* pointless if MU will be used */
 
 	  new_dp = (mp_ptr) dp + dn - (qn + 1);
 
diff -r 4942270f8f2a -r 7d46dceebe4c mpn/generic/perfpow.c
--- a/mpn/generic/perfpow.c	Sun Jun 15 01:27:26 2014 +0200
+++ b/mpn/generic/perfpow.c	Mon Jun 16 15:46:27 2014 +0200
@@ -2,7 +2,7 @@
 
    Contributed to the GNU project by Martin Boij.
 
-Copyright 2009, 2010, 2012 Free Software Foundation, Inc.
+Copyright 2009, 2010, 2012, 2014 Free Software Foundation, Inc.
 
 This file is part of the GNU MP Library.
 
@@ -175,6 +175,7 @@
   int ans;
   mp_bitcnt_t b;
   gmp_primesieve_t ps;
+  mp_ptr tmp;
   TMP_DECL;
 
   ASSERT (n > 0);
@@ -185,9 +186,11 @@
   gmp_init_primesieve (&ps);
   b = (f + 3) >> 1;
 
-  ip = TMP_ALLOC_LIMBS (n);
-  rp = TMP_ALLOC_LIMBS (n);
-  tp = TMP_ALLOC_LIMBS (5 * n);		/* FIXME */
+  tmp = TMP_ALLOC_LIMBS (7 * n);
+  ip = tmp; tmp += n;
+  rp = tmp; tmp += n;
+  tp = tmp; tmp += 5 * n;
+
   MPN_ZERO (rp, n);
 
   /* FIXME: It seems the inverse in ninv is needed only to get non-inverted
@@ -250,6 +253,7 @@
   mp_limb_t exp, *prev, *next, d, l, r, c, *tp, cry;
   mp_bitcnt_t twos, count;
   int ans, where, neg, trial;
+  mp_ptr tmp;
   TMP_DECL;
 
   nc = (mp_ptr) np;
@@ -318,9 +322,10 @@
 
       /* Remove factors found by trialdiv.  Optimization: Perhaps better to use
 	 the strategy in mpz_remove ().  */
-      prev = TMP_ALLOC_LIMBS (ncn + 2);
-      next = TMP_ALLOC_LIMBS (ncn + 2);
-      tp = TMP_ALLOC_LIMBS (4 * ncn);
+      tmp = TMP_ALLOC_LIMBS (6 * ncn + 4);
+      prev = tmp; tmp += ncn + 2;
+      next = tmp; tmp += ncn + 2;
+      tp = tmp; tmp += 4 * ncn;
 
       do
 	{


More information about the gmp-commit mailing list