summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/devel/try.c22
-rw-r--r--tests/refmpn.c38
-rw-r--r--tests/tests.h6
3 files changed, 55 insertions, 11 deletions
diff --git a/tests/devel/try.c b/tests/devel/try.c
index 772190bb2..b998cb5b8 100644
--- a/tests/devel/try.c
+++ b/tests/devel/try.c
@@ -561,6 +561,8 @@ validate_sqrtrem (void)
#define TYPE_MUL_1C 8
#define TYPE_MUL_2 9
+#define TYPE_MUL_3 92
+#define TYPE_MUL_4 93
#define TYPE_ADDMUL_1 10
#define TYPE_ADDMUL_1C 11
@@ -727,6 +729,16 @@ param_init (void)
p->overlap = OVERLAP_NOT_SRC2;
REFERENCE (refmpn_mul_2);
+ p = &param[TYPE_MUL_3];
+ COPY (TYPE_MUL_2);
+ p->msize = 3;
+ REFERENCE (refmpn_mul_3);
+
+ p = &param[TYPE_MUL_4];
+ COPY (TYPE_MUL_2);
+ p->msize = 4;
+ REFERENCE (refmpn_mul_4);
+
p = &param[TYPE_ADDMUL_1];
p->retval = 1;
@@ -1439,6 +1451,12 @@ const struct choice_t choice_array[] = {
#if HAVE_NATIVE_mpn_mul_2
{ TRY(mpn_mul_2), TYPE_MUL_2, 2 },
#endif
+#if HAVE_NATIVE_mpn_mul_3
+ { TRY(mpn_mul_3), TYPE_MUL_3, 3 },
+#endif
+#if HAVE_NATIVE_mpn_mul_4
+ { TRY(mpn_mul_4), TYPE_MUL_4, 4 },
+#endif
{ TRY(mpn_rshift), TYPE_RSHIFT },
{ TRY(mpn_lshift), TYPE_LSHIFT },
@@ -1958,10 +1976,12 @@ call (struct each_t *e, tryfun_t function)
break;
case TYPE_MUL_2:
+ case TYPE_MUL_3:
+ case TYPE_MUL_4:
if (size == 1)
abort ();
e->retval = CALLING_CONVENTIONS (function)
- (e->d[0].p, e->s[0].p, size, e->s[1].p);
+ (e->d[0].p, e->s[0].p, size, multiplier_N);
break;
case TYPE_ADDMUL_2:
diff --git a/tests/refmpn.c b/tests/refmpn.c
index bcb887c38..b2ceaa481 100644
--- a/tests/refmpn.c
+++ b/tests/refmpn.c
@@ -1,8 +1,8 @@
/* Reference mpn functions, designed to be simple, portable and independent
of the normal gmp code. Speed isn't a consideration.
-Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free
-Software Foundation, Inc.
+Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
+2007, 2008 Free Software Foundation, Inc.
This file is part of the GNU MP Library.
@@ -790,15 +790,17 @@ refmpn_mul_1 (mp_ptr rp, mp_srcptr sp, mp_size_t size, mp_limb_t multiplier)
mp_limb_t
-refmpn_mul_2 (mp_ptr dst, mp_srcptr src, mp_size_t size, mp_srcptr mult)
+refmpn_mul_N (mp_ptr dst, mp_srcptr src, mp_size_t size,
+ mp_srcptr mult, mp_size_t msize)
{
mp_ptr src_copy;
- mp_limb_t c;
+ mp_limb_t ret;
+ mp_size_t i;
ASSERT (refmpn_overlap_fullonly_p (dst, src, size));
- ASSERT (! refmpn_overlap_p (dst, size+1, mult, (mp_size_t) 2));
- ASSERT (size >= 1);
- ASSERT_MPN (mult, 2);
+ ASSERT (! refmpn_overlap_p (dst, size+msize-1, mult, msize));
+ ASSERT (size >= msize);
+ ASSERT_MPN (mult, msize);
/* in case dst==src */
src_copy = refmpn_malloc_limbs (size);
@@ -806,11 +808,29 @@ refmpn_mul_2 (mp_ptr dst, mp_srcptr src, mp_size_t size, mp_srcptr mult)
src = src_copy;
dst[size] = refmpn_mul_1 (dst, src, size, mult[0]);
- c = refmpn_addmul_1 (dst+1, src, size, mult[1]);
+ for (i = 1; i < msize-1; i++)
+ dst[size+i] = refmpn_addmul_1 (dst+i, src, size, mult[i]);
+ ret = refmpn_addmul_1 (dst+i, src, size, mult[i]);
+
free (src_copy);
- return c;
+ return ret;
}
+mp_limb_t
+refmpn_mul_2 (mp_ptr rp, mp_srcptr sp, mp_size_t size, mp_srcptr mult)
+{
+ return refmpn_mul_N (rp, sp, size, mult, (mp_size_t) 2);
+}
+mp_limb_t
+refmpn_mul_3 (mp_ptr rp, mp_srcptr sp, mp_size_t size, mp_srcptr mult)
+{
+ return refmpn_mul_N (rp, sp, size, mult, (mp_size_t) 3);
+}
+mp_limb_t
+refmpn_mul_4 (mp_ptr rp, mp_srcptr sp, mp_size_t size, mp_srcptr mult)
+{
+ return refmpn_mul_N (rp, sp, size, mult, (mp_size_t) 4);
+}
#define AORSMUL_1C(operation_n) \
{ \
diff --git a/tests/tests.h b/tests/tests.h
index 657ad2b74..c45667c11 100644
--- a/tests/tests.h
+++ b/tests/tests.h
@@ -294,7 +294,11 @@ mp_limb_t refmpn_mul_1 __GMP_PROTO ((mp_ptr wp, mp_srcptr xp, mp_size_t size,
mp_limb_t refmpn_mul_1c __GMP_PROTO ((mp_ptr wp, mp_srcptr xp, mp_size_t size,
mp_limb_t multiplier, mp_limb_t carry));
mp_limb_t refmpn_mul_2 __GMP_PROTO ((mp_ptr dst, mp_srcptr src, mp_size_t size,
- mp_srcptr mult));
+ mp_srcptr mult));
+mp_limb_t refmpn_mul_3 __GMP_PROTO ((mp_ptr dst, mp_srcptr src, mp_size_t size,
+ mp_srcptr mult));
+mp_limb_t refmpn_mul_4 __GMP_PROTO ((mp_ptr dst, mp_srcptr src, mp_size_t size,
+ mp_srcptr mult));
void refmpn_mul_basecase __GMP_PROTO ((mp_ptr prodp,
mp_srcptr up, mp_size_t usize,