[Gmp-commit] /home/hgfiles/gmp: Tests for mpn_rsblsh{2,}_n.

mercurial at gmplib.org mercurial at gmplib.org
Wed Dec 2 18:00:39 CET 2009


details:   /home/hgfiles/gmp/rev/9e60b40a32ad
changeset: 12959:9e60b40a32ad
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Wed Dec 02 18:00:31 2009 +0100
description:
Tests for mpn_rsblsh{2,}_n.

diffstat:

 ChangeLog         |   7 +++++++
 tests/devel/try.c |  21 +++++++++++++++++++++
 tests/refmpn.c    |  20 ++++++++++++++++++--
 tests/tests.h     |   2 ++
 4 files changed, 48 insertions(+), 2 deletions(-)

diffs (128 lines):

diff -r ee9ad3199449 -r 9e60b40a32ad ChangeLog
--- a/ChangeLog	Wed Dec 02 13:21:01 2009 +0100
+++ b/ChangeLog	Wed Dec 02 18:00:31 2009 +0100
@@ -1,3 +1,10 @@
+2009-12-02  Marco Bodrato <bodrato at mail.dm.unipi.it>
+
+	* tests/devel/try.c: Test mpn_rsblsh2_n and mpn_rsblsh_n.
+        * tests/refmpn.c (refmpn_rsblsh_n, refmpn_rsblsh2_n): New functions.
+	(refmpn_rsblsh1_n): Use generic refmpn_rsblsh_n.
+        * tests/tests.h: Declare new functions.
+
 2009-12-02  Torbjorn Granlund  <tege at gmplib.org>
 
 	* tune/speed.c (routine): Add mpn_binvert.
diff -r ee9ad3199449 -r 9e60b40a32ad tests/devel/try.c
--- a/tests/devel/try.c	Wed Dec 02 13:21:01 2009 +0100
+++ b/tests/devel/try.c	Wed Dec 02 18:00:31 2009 +0100
@@ -594,6 +594,8 @@
 #define TYPE_ADDLSH1_N        30
 #define TYPE_SUBLSH1_N        31
 #define TYPE_RSBLSH1_N        34
+#define TYPE_RSBLSH2_N        46
+#define TYPE_RSBLSH_N         47
 #define TYPE_RSH1ADD_N        32
 #define TYPE_RSH1SUB_N        33
 
@@ -900,6 +902,14 @@
   COPY (TYPE_ADD_N);
   REFERENCE (refmpn_rsblsh1_n);
 
+  p = &param[TYPE_RSBLSH2_N];
+  COPY (TYPE_ADD_N);
+  REFERENCE (refmpn_rsblsh2_n);
+
+  p = &param[TYPE_RSBLSH_N];
+  COPY (TYPE_ADD_N);
+  REFERENCE (refmpn_rsblsh_n);
+
   p = &param[TYPE_RSH1ADD_N];
   COPY (TYPE_ADD_N);
   REFERENCE (refmpn_rsh1add_n);
@@ -1442,6 +1452,12 @@
 #if HAVE_NATIVE_mpn_rsblsh1_n
   { TRY(mpn_rsblsh1_n), TYPE_RSBLSH1_N },
 #endif
+#if HAVE_NATIVE_mpn_rsblsh2_n
+  { TRY(mpn_rsblsh2_n), TYPE_RSBLSH2_N },
+#endif
+#if HAVE_NATIVE_mpn_rsblsh_n
+  { TRY(mpn_rsblsh_n), TYPE_RSBLSH_N },
+#endif
 #if HAVE_NATIVE_mpn_rsh1add_n
   { TRY(mpn_rsh1add_n), TYPE_RSH1ADD_N },
 #endif
@@ -2006,11 +2022,16 @@
   case TYPE_ADDLSH1_N:
   case TYPE_SUBLSH1_N:
   case TYPE_RSBLSH1_N:
+  case TYPE_RSBLSH2_N:
   case TYPE_RSH1ADD_N:
   case TYPE_RSH1SUB_N:
     e->retval = CALLING_CONVENTIONS (function)
       (e->d[0].p, e->s[0].p, e->s[1].p, size);
     break;
+  case TYPE_RSBLSH_N:
+    e->retval = CALLING_CONVENTIONS (function)
+      (e->d[0].p, e->s[0].p, e->s[1].p, size, shift);
+    break;
   case TYPE_ADD_NC:
   case TYPE_SUB_NC:
     e->retval = CALLING_CONVENTIONS (function)
diff -r ee9ad3199449 -r 9e60b40a32ad tests/refmpn.c
--- a/tests/refmpn.c	Wed Dec 02 13:21:01 2009 +0100
+++ b/tests/refmpn.c	Wed Dec 02 18:00:31 2009 +0100
@@ -644,23 +644,39 @@
   free (tp);
   return cy;
 }
+
 mp_limb_signed_t
-refmpn_rsblsh1_n (mp_ptr rp, mp_srcptr up, mp_srcptr vp, mp_size_t n)
+refmpn_rsblsh_n (mp_ptr rp, mp_srcptr up, mp_srcptr vp,
+		  mp_size_t n, unsigned int s)
 {
   mp_limb_signed_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, 1);
+  cy  = mpn_lshift (tp, vp, n, s);
   cy -= mpn_sub_n (rp, tp, up, n);
   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)
+{
+  return refmpn_rsblsh_n (rp, up, vp, n, 2);
+}
+
 mp_limb_t
 refmpn_rsh1add_n (mp_ptr rp, mp_srcptr up, mp_srcptr vp, mp_size_t n)
 {
diff -r ee9ad3199449 -r 9e60b40a32ad tests/tests.h
--- a/tests/tests.h	Wed Dec 02 13:21:01 2009 +0100
+++ b/tests/tests.h	Wed Dec 02 18:00:31 2009 +0100
@@ -375,6 +375,8 @@
                                     mp_limb_t multiplier, mp_limb_t carry));
 
 mp_limb_signed_t refmpn_rsblsh1_n __GMP_PROTO ((mp_ptr, mp_srcptr, mp_srcptr, mp_size_t));
+mp_limb_signed_t refmpn_rsblsh2_n __GMP_PROTO ((mp_ptr, mp_srcptr, mp_srcptr, mp_size_t));
+mp_limb_signed_t refmpn_rsblsh_n __GMP_PROTO ((mp_ptr, mp_srcptr, mp_srcptr, mp_size_t, unsigned int));
 
 void refmpn_tdiv_qr __GMP_PROTO ((mp_ptr qp, mp_ptr rp, mp_size_t qxn,
                              mp_ptr np, mp_size_t nsize,


More information about the gmp-commit mailing list