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

mercurial at gmplib.org mercurial at gmplib.org
Mon May 18 06:32:37 UTC 2015


details:   /var/hg/gmp/rev/95aa5ba8ba81
changeset: 16638:95aa5ba8ba81
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Mon May 18 08:31:36 2015 +0200
description:
gmp-h.in (mpn_neg): Niels' code using mpn_neg.

details:   /var/hg/gmp/rev/574539c50c47
changeset: 16639:574539c50c47
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Mon May 18 08:32:25 2015 +0200
description:
ChangeLog

diffstat:

 ChangeLog |   4 ++++
 gmp-h.in  |  22 ++++++++++++++--------
 2 files changed, 18 insertions(+), 8 deletions(-)

diffs (43 lines):

diff -r d57148a406f4 -r 574539c50c47 ChangeLog
--- a/ChangeLog	Sun May 17 20:41:29 2015 +0200
+++ b/ChangeLog	Mon May 18 08:32:25 2015 +0200
@@ -1,3 +1,7 @@
+2015-05-18 Marco Bodrato <bodrato at mail.dm.unipi.it>
+
+	* gmp-h.in (mpn_neg): Niels' code using mpn_neg.
+
 2015-05-17  Torbjörn Granlund  <torbjorng at google.com>
 
 	* mpn/arm/v6/sqr_basecase.asm: Rewrite for speed.
diff -r d57148a406f4 -r 574539c50c47 gmp-h.in
--- a/gmp-h.in	Sun May 17 20:41:29 2015 +0200
+++ b/gmp-h.in	Mon May 18 08:32:25 2015 +0200
@@ -2191,14 +2191,20 @@
 mp_limb_t
 mpn_neg (mp_ptr __gmp_rp, mp_srcptr __gmp_up, mp_size_t __gmp_n)
 {
-  mp_limb_t __gmp_ul, __gmp_cy;
-  __gmp_cy = 0;
-  do {
-      __gmp_ul = *__gmp_up++;
-      *__gmp_rp++ = -__gmp_ul - __gmp_cy;
-      __gmp_cy |= __gmp_ul != 0;
-  } while (--__gmp_n != 0);
-  return __gmp_cy;
+  while (*__gmp_up == 0) /* Low zero limbs are unchanged by negation. */
+    {
+      *__gmp_rp = 0;
+      if (!--__gmp_n) /* All zero */
+	return 0;
+      ++__gmp_up; ++__gmp_rp;
+    }
+
+  *__gmp_rp = (- *__gmp_up) & GMP_NUMB_MASK;
+
+  if (--__gmp_n) /* Higher limbs get complemented. */
+    mpn_com (++__gmp_rp, ++__gmp_up, __gmp_n);
+
+  return 1;
 }
 #endif
 


More information about the gmp-commit mailing list