[Gmp-commit] /home/hgfiles/gmp: 2 new changesets

mercurial at gmplib.org mercurial at gmplib.org
Fri Dec 18 08:14:00 CET 2009


details:   /home/hgfiles/gmp/rev/6c14ea063cbe
changeset: 13120:6c14ea063cbe
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Fri Dec 18 08:12:01 2009 +0100
description:
Use if (scratch == NULL) instead of if (!scratch).

details:   /home/hgfiles/gmp/rev/fca21e70aabb
changeset: 13121:fca21e70aabb
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Fri Dec 18 08:13:21 2009 +0100
description:
Move var declaration at the beginning of the function.

diffstat:

 mpn/generic/toom63_mul.c            |  23 ++++++-----------------
 mpn/generic/toom_interpolate_8pts.c |  15 ++++++++++-----
 2 files changed, 16 insertions(+), 22 deletions(-)

diffs (85 lines):

diff -r e967aaedb604 -r fca21e70aabb mpn/generic/toom63_mul.c
--- a/mpn/generic/toom63_mul.c	Fri Dec 18 07:59:50 2009 +0100
+++ b/mpn/generic/toom63_mul.c	Fri Dec 18 08:13:21 2009 +0100
@@ -23,25 +23,14 @@
 You should have received a copy of the GNU Lesser General Public License
 along with the GNU MP Library.  If not, see http://www.gnu.org/licenses/.  */
 
+/* FIXME: Write an _itch function, then remove NULL and TMP_*, as soon
+   as all the callers properly allocate and pass the scratch to the
+   function. */
+#include <stdlib.h>		/* for NULL */
+
 #include "gmp.h"
 #include "gmp-impl.h"
 
-#if HAVE_NATIVE_mpn_addlsh_n
-#define DO_mpn_addlsh_n(dst,src,n,s,ws) mpn_addlsh_n (dst,dst,src,n,s)
-#else
-static mp_limb_t
-DO_mpn_addlsh_n (mp_ptr dst, mp_srcptr src, mp_size_t n, unsigned int s, mp_ptr ws)
-{
-#if USE_MUL_1
-  return mpn_addmul_1(dst,src,n,CNST_LIMB(1) <<(s));
-#else
-  mp_limb_t __cy = mpn_lshift (ws,src,n,s);
-  return    __cy + mpn_add_n (dst,dst,ws,n);
-#endif
-}
-#endif
-
-
 /* Stores |{ap,n}-{bp,n}| in {rp,n}, returns the sign. */
 static int
 abs_sub_n (mp_ptr rp, mp_srcptr ap, mp_srcptr bp, mp_size_t n)
@@ -175,7 +164,7 @@
 
   /* Alloc also 3n+1 limbs for ws... mpn_toom_interpolate_8pts may
      need all of them, when DO_mpn_sublsh_n usea a scratch  */
-  if (!scratch) scratch = TMP_SALLOC_LIMBS (9 * n + 3);
+  if (scratch == NULL) scratch = TMP_SALLOC_LIMBS (9 * n + 3);
 
   /********************** evaluation and recursive calls *********************/
   /* $\pm4$ */
diff -r e967aaedb604 -r fca21e70aabb mpn/generic/toom_interpolate_8pts.c
--- a/mpn/generic/toom_interpolate_8pts.c	Fri Dec 18 07:59:50 2009 +0100
+++ b/mpn/generic/toom_interpolate_8pts.c	Fri Dec 18 08:13:21 2009 +0100
@@ -26,9 +26,15 @@
 #include "gmp.h"
 #include "gmp-impl.h"
 
+#define BINVERT_3 MODLIMB_INVERSE_3
+
 #ifndef mpn_divexact_by3
+#if HAVE_NATIVE_mpn_bdiv_q_1_pi1
+#define mpn_divexact_by3(dst,src,size) mpn_bdiv_q_1_pi1(dst,src,size,3,BINVERT_3,0)
+#else
 #define mpn_divexact_by3(dst,src,size) mpn_divexact_1(dst,src,size,3)
 #endif
+#endif
 
 #ifndef mpn_divexact_by45
 #define mpn_divexact_by45(dst,src,size) mpn_divexact_1(dst,src,size,45)
@@ -95,10 +101,10 @@
 			   mp_ptr r3, mp_ptr r7,
 			   mp_size_t spt, mp_ptr ws)
 {
-  mp_limb_t cy;
-
-  mp_ptr    r5 = (pp + 3 * n);			/* 3n+1 */
-  mp_ptr    r1 = (pp + 7 * n);			/* spt */
+  mp_limb_t cy, bw;
+  mp_ptr    r5, r1;
+  r5 = (pp + 3 * n);			/* 3n+1 */
+  r1 = (pp + 7 * n);			/* spt */
 
   /******************************* interpolation *****************************/
 
@@ -144,7 +150,6 @@
 				  ||-H*r5|-M_r5|-L_r5|
   */
 
-  mp_limb_t bw;
   bw = mpn_sub_n (r7, r7, r5, n);
   cy = mpn_add_n (pp + n, pp + n, r7, n); /* Hr8+Lr7-Lr5 */
   if (bw != cy) {


More information about the gmp-commit mailing list