[Gmp-commit] /home/hgfiles/gmp: Use sub_ddmmss in gcd_2.

mercurial at gmplib.org mercurial at gmplib.org
Thu Mar 11 16:21:08 CET 2010


details:   /home/hgfiles/gmp/rev/3a6fbda3a0c7
changeset: 13481:3a6fbda3a0c7
user:      Niels M?ller <nisse at lysator.liu.se>
date:      Thu Mar 11 16:21:03 2010 +0100
description:
Use sub_ddmmss in gcd_2.

diffstat:

 ChangeLog                |   2 ++
 mpn/generic/gcd_lehmer.c |  12 ++++++++----
 2 files changed, 10 insertions(+), 4 deletions(-)

diffs (46 lines):

diff -r 9bd5285aaab5 -r 3a6fbda3a0c7 ChangeLog
--- a/ChangeLog	Thu Mar 11 16:20:16 2010 +0100
+++ b/ChangeLog	Thu Mar 11 16:21:03 2010 +0100
@@ -1,5 +1,7 @@
 2010-03-11  Niels Möller  <nisse at lysator.liu.se>
 
+	* mpn/generic/gcd_lehmer.c (gcd_2): Use sub_ddmmss.
+
 	* mpn/generic/jacbase.c (mpn_jacobi_base): Reorganized the
 	JACOBI_BASE_METHOD 4 slightly. Now requires that b > 1.
 
diff -r 9bd5285aaab5 -r 3a6fbda3a0c7 mpn/generic/gcd_lehmer.c
--- a/mpn/generic/gcd_lehmer.c	Thu Mar 11 16:20:16 2010 +0100
+++ b/mpn/generic/gcd_lehmer.c	Thu Mar 11 16:21:03 2010 +0100
@@ -25,6 +25,12 @@
 #include "gmp-impl.h"
 #include "longlong.h"
 
+#if GMP_NAIL_BITS > 0
+/* Nail supports should be easy, replacing the sub_ddmmss with nails
+ * logic. */
+#error Nails not supported.
+#endif
+
 /* Use binary algorithm to compute G <-- GCD (U, V) for usize, vsize == 2.
    Both U and V must be odd. */
 static inline mp_size_t
@@ -48,16 +54,14 @@
       unsigned long int r;
       if (u1 > v1)
 	{
-	  u1 -= v1 + (u0 < v0);
-	  u0 = (u0 - v0) & GMP_NUMB_MASK;
+	  sub_ddmmss (u1, u0, u1, u0, v1, v0);
 	  count_trailing_zeros (r, u0);
 	  u0 = ((u1 << (GMP_NUMB_BITS - r)) & GMP_NUMB_MASK) | (u0 >> r);
 	  u1 >>= r;
 	}
       else  /* u1 < v1.  */
 	{
-	  v1 -= u1 + (v0 < u0);
-	  v0 = (v0 - u0) & GMP_NUMB_MASK;
+	  sub_ddmmss (v1, v0, v1, v0, u1, u0);
 	  count_trailing_zeros (r, v0);
 	  v0 = ((v1 << (GMP_NUMB_BITS - r)) & GMP_NUMB_MASK) | (v0 >> r);
 	  v1 >>= r;


More information about the gmp-commit mailing list