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

mercurial at gmplib.org mercurial at gmplib.org
Wed Sep 2 20:13:24 UTC 2015


details:   /var/hg/gmp/rev/514f6cce7e73
changeset: 16806:514f6cce7e73
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Wed Sep 02 22:04:57 2015 +0200
description:
mpn/generic/bsqrtinv.c: Use sqrlo+mullo_n instead of powlo(,,3,,).

details:   /var/hg/gmp/rev/fbd3ddd52a84
changeset: 16807:fbd3ddd52a84
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Wed Sep 02 22:12:49 2015 +0200
description:
mpq/div.c: Move a branch out of the normal flow.

details:   /var/hg/gmp/rev/4efbf8856a3d
changeset: 16808:4efbf8856a3d
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Wed Sep 02 22:13:16 2015 +0200
description:
ChangeLog

diffstat:

 ChangeLog              |   2 ++
 mpn/generic/bsqrtinv.c |  13 ++++++-------
 mpq/div.c              |  18 +++++++++---------
 3 files changed, 17 insertions(+), 16 deletions(-)

diffs (87 lines):

diff -r dd6e7b59d6d6 -r 4efbf8856a3d ChangeLog
--- a/ChangeLog	Tue Sep 01 22:10:48 2015 +0200
+++ b/ChangeLog	Wed Sep 02 22:13:16 2015 +0200
@@ -3,6 +3,8 @@
 	* mpq/cmp.c (mpq_cmp_numden): Cast to avoid over/underflow.
 	* tests/mpn/t-toom22.c (MIN_AN): Use defined value.
 	* tests/mpz/t-fac_ui.c: Check big factorial modulo a larger prime.
+	* mpn/generic/bsqrtinv.c: Use sqrlo+mullo_n instead of powlo(,,3,,).
+	* mpq/div.c: Move a branch out of the normal flow.
 
 2015-08-31  Torbjörn Granlund  <torbjorng at google.com>
 
diff -r dd6e7b59d6d6 -r 4efbf8856a3d mpn/generic/bsqrtinv.c
--- a/mpn/generic/bsqrtinv.c	Tue Sep 01 22:10:48 2015 +0200
+++ b/mpn/generic/bsqrtinv.c	Wed Sep 02 22:13:16 2015 +0200
@@ -2,7 +2,7 @@
 
    Contributed to the GNU project by Martin Boij (as part of perfpow.c).
 
-Copyright 2009, 2010, 2012 Free Software Foundation, Inc.
+Copyright 2009, 2010, 2012, 2015 Free Software Foundation, Inc.
 
 This file is part of the GNU MP Library.
 
@@ -55,8 +55,7 @@
 int
 mpn_bsqrtinv (mp_ptr rp, mp_srcptr yp, mp_bitcnt_t bnb, mp_ptr tp)
 {
-  mp_ptr tp2, tp3;
-  mp_limb_t k;
+  mp_ptr tp2;
   mp_size_t bn, order[GMP_LIMB_BITS + 1];
   int i, d;
 
@@ -65,8 +64,6 @@
   bn = 1 + bnb / GMP_LIMB_BITS;
 
   tp2 = tp + bn;
-  tp3 = tp + 2 * bn;
-  k = 3;
 
   rp[0] = 1;
   if (bnb == 1)
@@ -88,9 +85,11 @@
 	  bnb = order[i];
 	  bn = 1 + bnb / GMP_LIMB_BITS;
 
-	  mpn_mul_1 (tp, rp, bn, k);
+	  mpn_sqrlo (tp, rp, bn);
+	  mpn_mullo_n (tp2, rp, tp, bn); /* tp2 <- rp ^ 3 */
 
-	  mpn_powlo (tp2, rp, &k, 1, bn, tp3);
+	  mpn_mul_1 (tp, rp, bn, 3);
+
 	  mpn_mullo_n (rp, yp, tp2, bn);
 
 #if HAVE_NATIVE_mpn_rsh1sub_n
diff -r dd6e7b59d6d6 -r 4efbf8856a3d mpq/div.c
--- a/mpq/div.c	Tue Sep 01 22:10:48 2015 +0200
+++ b/mpq/div.c	Wed Sep 02 22:13:16 2015 +0200
@@ -47,17 +47,17 @@
   if (UNLIKELY (op2_size == 0))
     DIVIDE_BY_ZERO;
 
-  if (op1 == op2)
+  if (UNLIKELY (quot == op2))
     {
-      PTR(NUM(quot))[0] = 1;
-      SIZ(NUM(quot)) = 1;
-      PTR(DEN(quot))[0] = 1;
-      SIZ(DEN(quot)) = 1;
-      return;
-    }
+      if (op1 == op2)
+	{
+	  PTR(NUM(quot))[0] = 1;
+	  SIZ(NUM(quot)) = 1;
+	  PTR(DEN(quot))[0] = 1;
+	  SIZ(DEN(quot)) = 1;
+	  return;
+	}
 
-  if (quot == op2)
-    {
       /* We checked for op1 == op2: we are not in the x=x/x case.
 	 We compute x=y/x by computing x=inv(x)*y */
       MPN_PTR_SWAP (PTR(NUM(quot)), ALLOC(NUM(quot)),


More information about the gmp-commit mailing list