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

mercurial at gmplib.org mercurial at gmplib.org
Sun Sep 8 13:15:12 UTC 2019


details:   /var/hg/gmp/rev/9c7b6e29660a
changeset: 17874:9c7b6e29660a
user:      Torbjorn Granlund <tg at gmplib.org>
date:      Sat Sep 07 23:03:03 2019 +0200
description:
(HGCD2_METHOD=3 div1): Micro-optimise.

details:   /var/hg/gmp/rev/1e670b6883ce
changeset: 17875:1e670b6883ce
user:      Torbjorn Granlund <tg at gmplib.org>
date:      Sun Sep 08 15:15:04 2019 +0200
description:
(disabled div2): Micro-optimise.

diffstat:

 mpn/generic/hgcd2.c |  21 ++++++++++-----------
 1 files changed, 10 insertions(+), 11 deletions(-)

diffs (59 lines):

diff -r 8853a54686e3 -r 1e670b6883ce mpn/generic/hgcd2.c
--- a/mpn/generic/hgcd2.c	Sat Sep 07 20:50:57 2019 +0200
+++ b/mpn/generic/hgcd2.c	Sun Sep 08 15:15:04 2019 +0200
@@ -137,18 +137,18 @@
       d0 <<= 2;
 
       mask = -(mp_limb_t) (n0 >= d0);
+      n0 -= d0 & mask;
       q = 4 & mask;
-      n0 -= d0 & mask;
 
       d0 >>= 1;
       mask = -(mp_limb_t) (n0 >= d0);
+      n0 -= d0 & mask;
       q += 2 & mask;
-      n0 -= d0 & mask;
 
       d0 >>= 1;
       mask = -(mp_limb_t) (n0 >= d0);
-      q += 1 & mask;
       n0 -= d0 & mask;
+      q -= mask;
 
       res.d0 = n0;
       res.d1 = q;
@@ -239,16 +239,16 @@
 
   do
     {
-      mp_limb_t bit;
+      mp_limb_t mask;
       q <<= 1;
       if (UNLIKELY (nh == dh))
-	bit = (nl >= dl);
+	mask = -(nl >= dl);
       else
-	bit = (nh > dh);
+	mask = -(nh > dh);
 
-      q |= bit;
+      q -= mask;
 
-      sub_ddmmss (nh, nl, nh, nl, (-bit) & dh, (-bit) & dl);
+      sub_ddmmss (nh, nl, nh, nl, mask & dh, mask & dl);
 
       dl = (dh << (GMP_LIMB_BITS - 1)) | (dl >> 1);
       dh = dh >> 1;
@@ -396,9 +396,8 @@
 	}
     }
 
-  /* NOTE: Since we discard the least significant half limb, we don't
-     get a truly maximal M (corresponding to |a - b| <
-     2^{GMP_LIMB_BITS +1}). */
+  /* NOTE: Since we discard the least significant half limb, we don't get a
+     truly maximal M (corresponding to |a - b| < 2^{GMP_LIMB_BITS +1}). */
   /* Single precision loop */
   for (;;)
     {


More information about the gmp-commit mailing list