[Gmp-commit] /home/hgfiles/gmp: Tests for mpn_{add, sub}lsh_n, and mpn_addlsh2_n.

mercurial at gmplib.org mercurial at gmplib.org
Tue Dec 8 08:49:05 CET 2009


details:   /home/hgfiles/gmp/rev/336c0e91f5ca
changeset: 13004:336c0e91f5ca
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Tue Dec 08 08:48:57 2009 +0100
description:
Tests for mpn_{add,sub}lsh_n, and mpn_addlsh2_n.

diffstat:

 ChangeLog         |  10 ++++++++++
 acinclude.m4      |   2 +-
 tests/devel/try.c |  30 +++++++++++++++++++++++++++++-
 tests/refmpn.c    |  54 ++++++++++++++++++++++++++++++++++++------------------
 tests/tests.h     |   6 ++++++
 5 files changed, 82 insertions(+), 20 deletions(-)

diffs (232 lines):

diff -r af3f365253c5 -r 336c0e91f5ca ChangeLog
--- a/ChangeLog	Sun Dec 06 22:26:46 2009 +0100
+++ b/ChangeLog	Tue Dec 08 08:48:57 2009 +0100
@@ -1,3 +1,13 @@
+2009-12-08  Marco Bodrato <bodrato at mail.dm.unipi.it>
+
+	* tests/devel/try.c: Test mpn_addlsh2_n and mpn_{add,sub}lsh_n;
+	mpn_rsblsh_n now tests all shift values.
+	* tests/refmpn.c (refmpn_addlsh_n, refmpn_sublsh_n): New functions.
+	(refmpn_addlsh1_n): Use generic refmpn_addlsh_n.
+	(refmpn_sublsh1_n): Use generic refmpn_sublsh_n.
+	(refmpn_addlsh2_n): New function.
+	* tests/tests.h: Declare new functions.
+
 2009-12-06  Torbjorn Granlund  <tege at gmplib.org>
 
 	* tune/tuneup.c (tune_mulmod_bnm1): Up min_size to 12.
diff -r af3f365253c5 -r 336c0e91f5ca acinclude.m4
--- a/acinclude.m4	Sun Dec 06 22:26:46 2009 +0100
+++ b/acinclude.m4	Tue Dec 08 08:48:57 2009 +0100
@@ -112,7 +112,7 @@
 dnl  instead of gmp.h, since that file isn't generated until the end of the
 dnl  configure.
 dnl
-dnl  Dummy values for GMP_LIMB_BITS and GMP_LIMB_BITS are enough
+dnl  Dummy value for GMP_LIMB_BITS is enough
 dnl  for all current configure-time uses of gmp.h.
 
 define(GMP_INCLUDE_GMP_H,
diff -r af3f365253c5 -r 336c0e91f5ca tests/devel/try.c
--- a/tests/devel/try.c	Sun Dec 06 22:26:46 2009 +0100
+++ b/tests/devel/try.c	Tue Dec 08 08:48:57 2009 +0100
@@ -592,7 +592,10 @@
 #define TYPE_COM_N            28
 
 #define TYPE_ADDLSH1_N        30
+#define TYPE_ADDLSH2_N        48
+#define TYPE_ADDLSH_N         49
 #define TYPE_SUBLSH1_N        31
+#define TYPE_SUBLSH_N        130
 #define TYPE_RSBLSH1_N        34
 #define TYPE_RSBLSH2_N        46
 #define TYPE_RSBLSH_N         47
@@ -894,10 +897,23 @@
   COPY (TYPE_ADD_N);
   REFERENCE (refmpn_addlsh1_n);
 
+  p = &param[TYPE_ADDLSH2_N];
+  COPY (TYPE_ADD_N);
+  REFERENCE (refmpn_addlsh2_n);
+
+  p = &param[TYPE_ADDLSH_N];
+  COPY (TYPE_ADD_N);
+  p->shift = 1;
+  REFERENCE (refmpn_addlsh_n);
+
   p = &param[TYPE_SUBLSH1_N];
   COPY (TYPE_ADD_N);
   REFERENCE (refmpn_sublsh1_n);
 
+  p = &param[TYPE_SUBLSH_N];
+  COPY (TYPE_ADDLSH_N);
+  REFERENCE (refmpn_sublsh_n);
+
   p = &param[TYPE_RSBLSH1_N];
   COPY (TYPE_ADD_N);
   REFERENCE (refmpn_rsblsh1_n);
@@ -907,7 +923,7 @@
   REFERENCE (refmpn_rsblsh2_n);
 
   p = &param[TYPE_RSBLSH_N];
-  COPY (TYPE_ADD_N);
+  COPY (TYPE_ADDLSH_N);
   REFERENCE (refmpn_rsblsh_n);
 
   p = &param[TYPE_RSH1ADD_N];
@@ -1446,9 +1462,18 @@
 #if HAVE_NATIVE_mpn_addlsh1_n
   { TRY(mpn_addlsh1_n), TYPE_ADDLSH1_N },
 #endif
+#if HAVE_NATIVE_mpn_addlsh2_n
+  { TRY(mpn_addlsh2_n), TYPE_ADDLSH2_N },
+#endif
+#if HAVE_NATIVE_mpn_addlsh_n
+  { TRY(mpn_addlsh_n), TYPE_ADDLSH_N },
+#endif
 #if HAVE_NATIVE_mpn_sublsh1_n
   { TRY(mpn_sublsh1_n), TYPE_SUBLSH1_N },
 #endif
+#if HAVE_NATIVE_mpn_sublsh_n
+  { TRY(mpn_sublsh_n), TYPE_SUBLSH_N },
+#endif
 #if HAVE_NATIVE_mpn_rsblsh1_n
   { TRY(mpn_rsblsh1_n), TYPE_RSBLSH1_N },
 #endif
@@ -2020,6 +2045,7 @@
   case TYPE_ADD_N:
   case TYPE_SUB_N:
   case TYPE_ADDLSH1_N:
+  case TYPE_ADDLSH2_N:
   case TYPE_SUBLSH1_N:
   case TYPE_RSBLSH1_N:
   case TYPE_RSBLSH2_N:
@@ -2028,6 +2054,8 @@
     e->retval = CALLING_CONVENTIONS (function)
       (e->d[0].p, e->s[0].p, e->s[1].p, size);
     break;
+  case TYPE_ADDLSH_N:
+  case TYPE_SUBLSH_N:
   case TYPE_RSBLSH_N:
     e->retval = CALLING_CONVENTIONS (function)
       (e->d[0].p, e->s[0].p, e->s[1].p, size, shift);
diff -r af3f365253c5 -r 336c0e91f5ca tests/refmpn.c
--- a/tests/refmpn.c	Sun Dec 06 22:26:46 2009 +0100
+++ b/tests/refmpn.c	Tue Dec 08 08:48:57 2009 +0100
@@ -611,43 +611,63 @@
 }
 
 mp_limb_t
-refmpn_addlsh1_n (mp_ptr rp, mp_srcptr up, mp_srcptr vp, mp_size_t n)
+refmpn_addlsh_n (mp_ptr rp, mp_srcptr up, mp_srcptr vp,
+		 mp_size_t n, unsigned int s)
 {
   mp_limb_t cy;
   mp_ptr tp;
 
   ASSERT (refmpn_overlap_fullonly_two_p (rp, up, vp, n));
   ASSERT (n >= 1);
+  ASSERT (0 < s && s < GMP_NUMB_BITS);
   ASSERT_MPN (up, n);
   ASSERT_MPN (vp, n);
 
   tp = refmpn_malloc_limbs (n);
-  cy  = refmpn_lshift (tp, vp, n, 1);
+  cy  = refmpn_lshift (tp, vp, n, s);
   cy += refmpn_add_n (rp, up, tp, n);
   free (tp);
   return cy;
 }
 mp_limb_t
+refmpn_addlsh1_n (mp_ptr rp, mp_srcptr up, mp_srcptr vp, mp_size_t n)
+{
+  return refmpn_addlsh_n (rp, up, vp, n, 1);
+}
+mp_limb_t
+refmpn_addlsh2_n (mp_ptr rp, mp_srcptr up, mp_srcptr vp, mp_size_t n)
+{
+  return refmpn_addlsh_n (rp, up, vp, n, 2);
+}
+
+mp_limb_t
+refmpn_sublsh_n (mp_ptr rp, mp_srcptr up, mp_srcptr vp,
+		 mp_size_t n, unsigned int s)
+{
+  mp_limb_t cy;
+  mp_ptr tp;
+
+  ASSERT (refmpn_overlap_fullonly_two_p (rp, up, vp, n));
+  ASSERT (n >= 1);
+  ASSERT (0 < s && s < GMP_NUMB_BITS);
+  ASSERT_MPN (up, n);
+  ASSERT_MPN (vp, n);
+
+  tp = refmpn_malloc_limbs (n);
+  cy  = mpn_lshift (tp, vp, n, s);
+  cy += mpn_sub_n (rp, up, tp, n);
+  free (tp);
+  return cy;
+}
+mp_limb_t
 refmpn_sublsh1_n (mp_ptr rp, mp_srcptr up, mp_srcptr vp, mp_size_t n)
 {
-  mp_limb_t cy;
-  mp_ptr tp;
-
-  ASSERT (refmpn_overlap_fullonly_two_p (rp, up, vp, n));
-  ASSERT (n >= 1);
-  ASSERT_MPN (up, n);
-  ASSERT_MPN (vp, n);
-
-  tp = refmpn_malloc_limbs (n);
-  cy  = mpn_lshift (tp, vp, n, 1);
-  cy += mpn_sub_n (rp, up, tp, n);
-  free (tp);
-  return cy;
+  return refmpn_sublsh_n (rp, up, vp, n, 1);
 }
 
 mp_limb_signed_t
 refmpn_rsblsh_n (mp_ptr rp, mp_srcptr up, mp_srcptr vp,
-		  mp_size_t n, unsigned int s)
+		 mp_size_t n, unsigned int s)
 {
   mp_limb_signed_t cy;
   mp_ptr tp;
@@ -664,13 +684,11 @@
   free (tp);
   return cy;
 }
-
 mp_limb_signed_t
 refmpn_rsblsh1_n (mp_ptr rp, mp_srcptr up, mp_srcptr vp, mp_size_t n)
 {
   return refmpn_rsblsh_n (rp, up, vp, n, 1);
 }
-
 mp_limb_signed_t
 refmpn_rsblsh2_n (mp_ptr rp, mp_srcptr up, mp_srcptr vp, mp_size_t n)
 {
diff -r af3f365253c5 -r 336c0e91f5ca tests/tests.h
--- a/tests/tests.h	Sun Dec 06 22:26:46 2009 +0100
+++ b/tests/tests.h	Tue Dec 08 08:48:57 2009 +0100
@@ -183,6 +183,10 @@
                                  mp_size_t size, mp_limb_t carry));
 mp_limb_t refmpn_addlsh1_n __GMP_PROTO ((mp_ptr wp, mp_srcptr xp, mp_srcptr yp,
                                 mp_size_t size));
+mp_limb_t refmpn_addlsh2_n __GMP_PROTO ((mp_ptr wp, mp_srcptr xp, mp_srcptr yp,
+                                mp_size_t size));
+mp_limb_t refmpn_addlsh_n __GMP_PROTO ((mp_ptr wp, mp_srcptr xp, mp_srcptr yp,
+                                mp_size_t size, unsigned int));
 mp_limb_t refmpn_addmul_1 __GMP_PROTO ((mp_ptr wp, mp_srcptr xp, mp_size_t size,
                                    mp_limb_t multiplier));
 mp_limb_t refmpn_addmul_1c __GMP_PROTO ((mp_ptr wp, mp_srcptr xp, mp_size_t size,
@@ -369,6 +373,8 @@
                                  mp_size_t size, mp_limb_t carry));
 mp_limb_t refmpn_sublsh1_n __GMP_PROTO ((mp_ptr wp, mp_srcptr xp, mp_srcptr yp,
                                 mp_size_t size));
+mp_limb_t refmpn_sublsh_n __GMP_PROTO ((mp_ptr wp, mp_srcptr xp, mp_srcptr yp,
+                                mp_size_t size, unsigned int));
 mp_limb_t refmpn_submul_1 __GMP_PROTO ((mp_ptr wp, mp_srcptr xp, mp_size_t size,
                                    mp_limb_t multiplier));
 mp_limb_t refmpn_submul_1c __GMP_PROTO ((mp_ptr wp, mp_srcptr xp, mp_size_t size,


More information about the gmp-commit mailing list