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

mercurial at gmplib.org mercurial at gmplib.org
Sun Feb 26 09:02:53 UTC 2017


details:   /var/hg/gmp/rev/e2738ad981f0
changeset: 17312:e2738ad981f0
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Sun Feb 26 08:44:33 2017 +0100
description:
mpn/generic/pow_1.c: Use umul_ppmm for a single limb.

details:   /var/hg/gmp/rev/c3927196a330
changeset: 17313:c3927196a330
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Sun Feb 26 08:51:08 2017 +0100
description:
Changelog

diffstat:

 ChangeLog           |   8 ++++++--
 mpn/generic/pow_1.c |  12 +++++++-----
 2 files changed, 13 insertions(+), 7 deletions(-)

diffs (54 lines):

diff -r c5b84d3614b1 -r c3927196a330 ChangeLog
--- a/ChangeLog	Sat Feb 25 22:20:27 2017 +0100
+++ b/ChangeLog	Sun Feb 26 08:51:08 2017 +0100
@@ -1,3 +1,7 @@
+2017-02-26 Marco Bodrato <bodrato at mail.dm.unipi.it>
+
+	* mpn/generic/pow_1.c: Use umul_ppmm for a single limb.
+
 2017-02-25  Torbjörn Granlund  <tg at gmplib.org>
 
 	* configure.ac: Allow MP_SIZE_T_MAX for threasholds exported to
@@ -10,8 +14,8 @@
 
 2017-02-24  Torbjörn Granlund  <tg at gmplib.org>
 
-	* longlong.h (arm32/arm64 add_sssaaaa): Use "subs" for some immediates.
-	* longlong.h (arm32/arm64 sub_sssaaaa): Use "adds" for some immediates.
+	* longlong.h (arm32/arm64 add_ssaaaa): Use "subs" for some immediates.
+	* longlong.h (arm32/arm64 sub_ssaaaa): Use "adds" for some immediates.
 
 	* mpn/arm64/copyi.asm: Avoid branching on flags.
 	* mpn/arm64/copyd.asm: Likewise.
diff -r c5b84d3614b1 -r c3927196a330 mpn/generic/pow_1.c
--- a/mpn/generic/pow_1.c	Sat Feb 25 22:20:27 2017 +0100
+++ b/mpn/generic/pow_1.c	Sun Feb 26 08:51:08 2017 +0100
@@ -78,21 +78,23 @@
 
   if (bn == 1)
     {
-      mp_limb_t bl = bp[0];
+      mp_limb_t rl, rh, bl = bp[0];
 
       if ((cnt & 1) != 0)
 	MP_PTR_SWAP (rp, tp);
 
-      mpn_sqr (rp, bp, bn);
-      rn = 2 * bn; rn -= rp[rn - 1] == 0;
+      umul_ppmm (rh, rl, bl, bl << GMP_NAIL_BITS);
+      rp[0] = rl >> GMP_NAIL_BITS;
+      rp[1] = rh;
+      rn = 1 + (rh != 0);
 
       for (i = GMP_LIMB_BITS - cnt - 1;;)
 	{
 	  exp <<= 1;
 	  if ((exp & GMP_LIMB_HIGHBIT) != 0)
 	    {
-	      rp[rn] = mpn_mul_1 (rp, rp, rn, bl);
-	      rn += rp[rn] != 0;
+	      rp[rn] = rh = mpn_mul_1 (rp, rp, rn, bl);
+	      rn += rh != 0;
 	    }
 
 	  if (--i == 0)


More information about the gmp-commit mailing list