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

mercurial at gmplib.org mercurial at gmplib.org
Sun May 20 23:36:14 CEST 2012


details:   /var/hg/gmp/rev/da4ad3c60bf9
changeset: 14990:da4ad3c60bf9
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Sun May 20 23:33:26 2012 +0200
description:
typo.

details:   /var/hg/gmp/rev/d8256265fec3
changeset: 14991:d8256265fec3
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Sun May 20 23:34:16 2012 +0200
description:
Remove a wrong LIKELY()

details:   /var/hg/gmp/rev/822e81d2bede
changeset: 14992:822e81d2bede
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Sun May 20 23:36:07 2012 +0200
description:
mpn/generic/toom8_sqr.c: Reduce branches for recursion.

diffstat:

 ChangeLog                            |   4 ++
 mpn/generic/toom8_sqr.c              |  59 ++++++++++++++++++++---------------
 mpn/generic/toom_interpolate_16pts.c |   2 +-
 mpn/generic/toom_interpolate_6pts.c  |   2 +-
 4 files changed, 39 insertions(+), 28 deletions(-)

diffs (149 lines):

diff -r 8957fc7608ad -r 822e81d2bede ChangeLog
--- a/ChangeLog	Sun May 20 20:43:40 2012 +0200
+++ b/ChangeLog	Sun May 20 23:36:07 2012 +0200
@@ -1,3 +1,7 @@
+2012-05-21 Marco Bodrato <bodrato at mail.dm.unipi.it>
+
+	* mpn/generic/toom8_sqr.c: Reduce branches for recursion.
+
 2012-05-20  Torbjorn Granlund  <tege at gmplib.org>
 
 	* tests/mpz/t-gcd.c: Rewrite.
diff -r 8957fc7608ad -r 822e81d2bede mpn/generic/toom8_sqr.c
--- a/mpn/generic/toom8_sqr.c	Sun May 20 20:43:40 2012 +0200
+++ b/mpn/generic/toom8_sqr.c	Sun May 20 23:36:07 2012 +0200
@@ -82,25 +82,32 @@
   (SQR_TOOM8_MAX >= SQR_TOOM8_THRESHOLD)
 #endif
 
-#define TOOM8_SQR_REC(p, a, n, ws)					\
+#define TOOM8_SQR_REC(p, a, f, p2, a2, n, ws)				\
   do {									\
     if (MAYBE_sqr_basecase && ( !MAYBE_sqr_above_basecase		\
-	|| BELOW_THRESHOLD (n, SQR_TOOM2_THRESHOLD)))			\
+	|| BELOW_THRESHOLD (n, SQR_TOOM2_THRESHOLD))) {			\
       mpn_sqr_basecase (p, a, n);					\
-    else if (MAYBE_sqr_toom2 && ( !MAYBE_sqr_above_toom2		\
-	     || BELOW_THRESHOLD (n, SQR_TOOM3_THRESHOLD)))		\
+      if (f) mpn_sqr_basecase (p2, a2, n);				\
+    } else if (MAYBE_sqr_toom2 && ( !MAYBE_sqr_above_toom2		\
+	     || BELOW_THRESHOLD (n, SQR_TOOM3_THRESHOLD))) {		\
       mpn_toom2_sqr (p, a, n, ws);					\
-    else if (MAYBE_sqr_toom3 && ( !MAYBE_sqr_above_toom3		\
-	     || BELOW_THRESHOLD (n, SQR_TOOM4_THRESHOLD)))		\
+      if (f) mpn_toom2_sqr (p2, a2, n, ws);				\
+    } else if (MAYBE_sqr_toom3 && ( !MAYBE_sqr_above_toom3		\
+	     || BELOW_THRESHOLD (n, SQR_TOOM4_THRESHOLD))) {		\
       mpn_toom3_sqr (p, a, n, ws);					\
-    else if (MAYBE_sqr_toom4 && ( !MAYBE_sqr_above_toom4		\
-	     || BELOW_THRESHOLD (n, SQR_TOOM6_THRESHOLD)))		\
+      if (f) mpn_toom3_sqr (p2, a2, n, ws);				\
+    } else if (MAYBE_sqr_toom4 && ( !MAYBE_sqr_above_toom4		\
+	     || BELOW_THRESHOLD (n, SQR_TOOM6_THRESHOLD))) {		\
       mpn_toom4_sqr (p, a, n, ws);					\
-    else if (! MAYBE_sqr_above_toom6					\
-	     || BELOW_THRESHOLD (n, SQR_TOOM8_THRESHOLD))		\
+      if (f) mpn_toom4_sqr (p2, a2, n, ws);				\
+    } else if (! MAYBE_sqr_above_toom6					\
+	     || BELOW_THRESHOLD (n, SQR_TOOM8_THRESHOLD)) {		\
       mpn_toom6_sqr (p, a, n, ws);					\
-    else								\
+      if (f) mpn_toom6_sqr (p2, a2, n, ws);				\
+    } else {								\
       mpn_toom8_sqr (p, a, n, ws);					\
+      if (f) mpn_toom8_sqr (p2, a2, n, ws);				\
+    }									\
   } while (0)
 
 void
@@ -139,51 +146,51 @@
   /********************** evaluation and recursive calls *********************/
   /* $\pm1/8$ */
   mpn_toom_eval_pm2rexp (v2, v0, 7, ap, n, s, 3, pp);
-  TOOM8_SQR_REC(pp, v0, n + 1, wse); /* A(-1/8)*B(-1/8)*8^. */
-  TOOM8_SQR_REC(r7, v2, n + 1, wse); /* A(+1/8)*B(+1/8)*8^. */
+  /* A(-1/8)*B(-1/8)*8^. */ /* A(+1/8)*B(+1/8)*8^. */
+  TOOM8_SQR_REC(pp, v0, 2, r7, v2, n + 1, wse);
   mpn_toom_couple_handling (r7, 2 * n + 1 + BIT_CORRECTION, pp, 0, n, 3, 0);
 
   /* $\pm1/4$ */
   mpn_toom_eval_pm2rexp (v2, v0, 7, ap, n, s, 2, pp);
-  TOOM8_SQR_REC(pp, v0, n + 1, wse); /* A(-1/4)*B(-1/4)*4^. */
-  TOOM8_SQR_REC(r5, v2, n + 1, wse); /* A(+1/4)*B(+1/4)*4^. */
+  /* A(-1/4)*B(-1/4)*4^. */ /* A(+1/4)*B(+1/4)*4^. */
+  TOOM8_SQR_REC(pp, v0, 2, r5, v2, n + 1, wse);
   mpn_toom_couple_handling (r5, 2 * n + 1, pp, 0, n, 2, 0);
 
   /* $\pm2$ */
   mpn_toom_eval_pm2 (v2, v0, 7, ap, n, s, pp);
-  TOOM8_SQR_REC(pp, v0, n + 1, wse); /* A(-2)*B(-2) */
-  TOOM8_SQR_REC(r3, v2, n + 1, wse); /* A(+2)*B(+2) */
+  /* A(-2)*B(-2) */ /* A(+2)*B(+2) */
+  TOOM8_SQR_REC(pp, v0, 2, r3, v2, n + 1, wse);
   mpn_toom_couple_handling (r3, 2 * n + 1, pp, 0, n, 1, 2);
 
   /* $\pm8$ */
   mpn_toom_eval_pm2exp (v2, v0, 7, ap, n, s, 3, pp);
-  TOOM8_SQR_REC(pp, v0, n + 1, wse); /* A(-8)*B(-8) */
-  TOOM8_SQR_REC(r1, v2, n + 1, wse); /* A(+8)*B(+8) */
+  /* A(-8)*B(-8) */ /* A(+8)*B(+8) */
+  TOOM8_SQR_REC(pp, v0, 2, r1, v2, n + 1, wse);
   mpn_toom_couple_handling (r1, 2 * n + 1 + BIT_CORRECTION, pp, 0, n, 3, 6);
 
   /* $\pm1/2$ */
   mpn_toom_eval_pm2rexp (v2, v0, 7, ap, n, s, 1, pp);
-  TOOM8_SQR_REC(pp, v0, n + 1, wse); /* A(-1/2)*B(-1/2)*2^. */
-  TOOM8_SQR_REC(r6, v2, n + 1, wse); /* A(+1/2)*B(+1/2)*2^. */
+  /* A(-1/2)*B(-1/2)*2^. */ /* A(+1/2)*B(+1/2)*2^. */
+  TOOM8_SQR_REC(pp, v0, 2, r6, v2, n + 1, wse);
   mpn_toom_couple_handling (r6, 2 * n + 1, pp, 0, n, 1, 0);
 
   /* $\pm1$ */
   mpn_toom_eval_pm1 (v2, v0, 7, ap, n, s,    pp);
-  TOOM8_SQR_REC(pp, v0, n + 1, wse); /* A(-1)*B(-1) */
-  TOOM8_SQR_REC(r4, v2, n + 1, wse); /* A(1)*B(1) */
+  /* A(-1)*B(-1) */ /* A(1)*B(1) */
+  TOOM8_SQR_REC(pp, v0, 2, r4, v2, n + 1, wse);
   mpn_toom_couple_handling (r4, 2 * n + 1, pp, 0, n, 0, 0);
 
   /* $\pm4$ */
   mpn_toom_eval_pm2exp (v2, v0, 7, ap, n, s, 2, pp);
-  TOOM8_SQR_REC(pp, v0, n + 1, wse); /* A(-4)*B(-4) */
-  TOOM8_SQR_REC(r2, v2, n + 1, wse); /* A(+4)*B(+4) */
+  /* A(-4)*B(-4) */ /* A(+4)*B(+4) */
+  TOOM8_SQR_REC(pp, v0, 2, r2, v2, n + 1, wse);
   mpn_toom_couple_handling (r2, 2 * n + 1, pp, 0, n, 2, 4);
 
 #undef v0
 #undef v2
 
   /* A(0)*B(0) */
-  TOOM8_SQR_REC(pp, ap, n, wse);
+  TOOM8_SQR_REC(pp, ap, 0, pp, ap, n, wse);
 
   mpn_toom_interpolate_16pts (pp, r1, r3, r5, r7, n, 2 * s, 0, wse);
 
diff -r 8957fc7608ad -r 822e81d2bede mpn/generic/toom_interpolate_16pts.c
--- a/mpn/generic/toom_interpolate_16pts.c	Sun May 20 20:43:40 2012 +0200
+++ b/mpn/generic/toom_interpolate_16pts.c	Sun May 20 23:36:07 2012 +0200
@@ -378,7 +378,7 @@
   mpn_divexact_by255x188513325(r7, r7, n3p1);
 
   mpn_submul_1 (r5, r7, n3p1, 12567555); /* can be negative */
-  /* A division by 2835x64 followsi. Warning: the operand can be negative! */
+  /* A division by 2835x64 follows. Warning: the operand can be negative! */
   mpn_divexact_by2835x64(r5, r5, n3p1);
   if ((r5[n3] & (GMP_NUMB_MAX << (GMP_NUMB_BITS-7))) != 0)
     r5[n3] |= (GMP_NUMB_MAX << (GMP_NUMB_BITS-6));
diff -r 8957fc7608ad -r 822e81d2bede mpn/generic/toom_interpolate_6pts.c
--- a/mpn/generic/toom_interpolate_6pts.c	Sun May 20 20:43:40 2012 +0200
+++ b/mpn/generic/toom_interpolate_6pts.c	Sun May 20 23:36:07 2012 +0200
@@ -210,7 +210,7 @@
   embankment = w0[w0n - 1] - 1;
   w0[w0n - 1] = 1;
   if (LIKELY (w0n > n)) {
-    if ( LIKELY(cy4 > cy6) )
+    if (cy4 > cy6)
       MPN_INCR_U (pp + 4 * n, w0n + n, cy4 - cy6);
     else
       MPN_DECR_U (pp + 4 * n, w0n + n, cy6 - cy4);


More information about the gmp-commit mailing list