[Gmp-commit] /home/hgfiles/gmp: Use mpn_rsblsh2_n ;-)

mercurial at gmplib.org mercurial at gmplib.org
Mon Nov 30 17:19:23 CET 2009


details:   /home/hgfiles/gmp/rev/3ef05c6953ac
changeset: 12943:3ef05c6953ac
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Mon Nov 30 17:18:36 2009 +0100
description:
Use mpn_rsblsh2_n ;-)

diffstat:

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

diffs (62 lines):

diff -r 7eee361037ad -r 3ef05c6953ac ChangeLog
--- a/ChangeLog	Mon Nov 30 11:42:12 2009 +0100
+++ b/ChangeLog	Mon Nov 30 17:18:36 2009 +0100
@@ -1,3 +1,7 @@
+2009-11-30  Marco Bodrato <bodrato at mail.dm.unipi.it>
+
+	* mpn/generic/fib2_ui.c: Use mpn_rsblsh2_n.
+
 2009-11-29  Torbjorn Granlund  <tege at gmplib.org>
 
 	* mpn/x86_64/pentium4/gmp-mparam.h
diff -r 7eee361037ad -r 3ef05c6953ac mpn/generic/fib2_ui.c
--- a/mpn/generic/fib2_ui.c	Mon Nov 30 11:42:12 2009 +0100
+++ b/mpn/generic/fib2_ui.c	Mon Nov 30 17:18:36 2009 +0100
@@ -24,8 +24,6 @@
 #include <stdio.h>
 #include "gmp.h"
 #include "gmp-impl.h"
-#include "longlong.h"
-
 
 /* change this to "#define TRACE(x) x" for diagnostics */
 #define TRACE(x)
@@ -65,7 +63,6 @@
   mp_ptr         xp, yp;
   mp_size_t      size;
   unsigned long  nfirst, mask;
-  TMP_DECL;
 
   TRACE (printf ("mpn_fib2_ui n=%lu\n", n));
 
@@ -85,6 +82,7 @@
   if (mask != 1)
     {
       mp_size_t  alloc;
+      TMP_DECL;
 
       TMP_MARK;
       alloc = MPN_FIB2_SIZE (n);
@@ -127,15 +125,21 @@
 
 	  /* Calculate F[2k+1] = 4*F[k]^2 - F[k-1]^2 + 2*(-1)^k.
 	     n&mask is the low bit of our implied k.  */
+#if HAVE_NATIVE_mpn_rsblsh2_n
+	  fp[size] = mpn_rsblsh2_n (fp, yp, xp, size);
+	  if ((n & mask) == 0) MPN_INCR_U(fp, size + 1, 2);
+	  c = fp[size];
+#else
 	  c = mpn_lshift (fp, xp, size, 2);
 	  fp[0] |= (n & mask ? 0 : 2);	 /* possible +2 */
 	  c -= mpn_sub_n (fp, fp, yp, size);
+	  fp[size] = c;
+#endif
 	  ASSERT (n & (mask << 1) ? fp[0] != 0 && fp[0] != 1 : 1);
 	  fp[0] -= (n & mask ? 2 : 0);	 /* possible -2 */
 	  ASSERT (alloc >= size+1);
 	  xp[size] = 0;
 	  yp[size] = 0;
-	  fp[size] = c;
 	  size += (c != 0);
 
 	  /* Calculate F[2k-1] = F[k]^2 + F[k-1]^2.


More information about the gmp-commit mailing list