[Gmp-commit] /var/hg/gmp: 2 new changesets
mercurial at gmplib.org
mercurial at gmplib.org
Sat Mar 24 23:47:31 UTC 2018
details: /var/hg/gmp/rev/54209af79098
changeset: 17590:54209af79098
user: Torbjorn Granlund <tg at gmplib.org>
date: Sun Mar 25 00:46:20 2018 +0100
description:
"riscv" => "riscv64"
details: /var/hg/gmp/rev/2a3b146aee90
changeset: 17591:2a3b146aee90
user: Torbjorn Granlund <tg at gmplib.org>
date: Sun Mar 25 00:47:27 2018 +0100
description:
Trivial merge.
diffstat:
ChangeLog | 6 ++++
configure.ac | 2 +-
mpn/generic/sec_powm.c | 67 ++++++++++++++++++++++++++-----------------------
3 files changed, 42 insertions(+), 33 deletions(-)
diffs (167 lines):
diff -r 186ea964d61f -r 2a3b146aee90 ChangeLog
--- a/ChangeLog Fri Mar 23 15:01:49 2018 +0100
+++ b/ChangeLog Sun Mar 25 00:47:27 2018 +0100
@@ -1,3 +1,9 @@
+2018-03-23 Torbjörn Granlund <tg at gmplib.org>
+
+ * mpn/generic/sec_powm.c: Remove unused macros.
+ Simplify code for choosing between redc_1 and redc_2.
+ Compute power table with squaring for even powers.
+
2018-02-28 Marco Bodrato <bodrato at mail.dm.unipi.it>
* gmpxx.h (__gmp_binary_plus): Special case for mpq + 1.
diff -r 186ea964d61f -r 2a3b146aee90 configure.ac
--- a/configure.ac Fri Mar 23 15:01:49 2018 +0100
+++ b/configure.ac Sun Mar 25 00:47:27 2018 +0100
@@ -1299,7 +1299,7 @@
# RISC-V
- [riscv-*-*])
+ [riscv64-*-*])
cclist="gcc"
path="riscv/64"
;;
diff -r 186ea964d61f -r 2a3b146aee90 mpn/generic/sec_powm.c
--- a/mpn/generic/sec_powm.c Fri Mar 23 15:01:49 2018 +0100
+++ b/mpn/generic/sec_powm.c Sun Mar 25 00:47:27 2018 +0100
@@ -3,7 +3,7 @@
Contributed to the GNU project by Torbjörn Granlund.
-Copyright 2007-2009, 2011-2014 Free Software Foundation, Inc.
+Copyright 2007-2009, 2011-2014, 2018 Free Software Foundation, Inc.
This file is part of the GNU MP Library.
@@ -70,6 +70,7 @@
mpn_cnd_sub_n (cy, rp, rp, mp, n); \
} while (0)
+#if HAVE_NATIVE_mpn_addmul_2 || HAVE_NATIVE_mpn_redc_2
#undef MPN_REDC_2_SEC
#define MPN_REDC_2_SEC(rp, up, mp, n, mip) \
do { \
@@ -77,9 +78,10 @@
cy = mpn_redc_2 (rp, up, mp, n, mip); \
mpn_cnd_sub_n (cy, rp, rp, mp, n); \
} while (0)
-
-#if HAVE_NATIVE_mpn_addmul_2 || HAVE_NATIVE_mpn_redc_2
-#define WANT_REDC_2 1
+#else
+#define MPN_REDC_2_SEC(rp, up, mp, n, mip) /* empty */
+#undef REDC_1_TO_REDC_2_THRESHOLD
+#define REDC_1_TO_REDC_2_THRESHOLD MP_SIZE_T_MAX
#endif
/* Define our own mpn squaring function. We do this since we cannot use a
@@ -206,7 +208,7 @@
mp_limb_t ip[2], *mip;
int windowsize, this_windowsize;
mp_limb_t expbits;
- mp_ptr pp, this_pp;
+ mp_ptr pp, this_pp, ps;
long i;
int cnd;
@@ -219,7 +221,6 @@
windowsize = win_size (enb);
-#if WANT_REDC_2
if (BELOW_THRESHOLD (n, REDC_1_TO_REDC_2_THRESHOLD))
{
mip = ip;
@@ -232,11 +233,6 @@
mpn_binvert (mip, mp, 2, tp);
mip[0] = -mip[0]; mip[1] = ~mip[1];
}
-#else
- mip = ip;
- binvert_limb (mip[0], mp[0]);
- mip[0] = -mip[0];
-#endif
pp = tp;
tp += (n << windowsize); /* put tp after power table */
@@ -259,18 +255,34 @@
/* Precompute powers of b and put them in the temporary area at pp. */
/* scratch: | n | n | ... | | 2n | */
/* | pp[0] | pp[1] | ... | pp[2^windowsize-1] | product | */
- for (i = (1 << windowsize) - 2; i > 0; i--)
+ ps = pp + n; /* initially B^1 */
+ if (BELOW_THRESHOLD (n, REDC_1_TO_REDC_2_THRESHOLD))
{
- mpn_mul_basecase (tp, this_pp, n, pp + n, n);
- this_pp += n;
-#if WANT_REDC_2
- if (BELOW_THRESHOLD (n, REDC_1_TO_REDC_2_THRESHOLD))
- MPN_REDC_1_SEC (this_pp, tp, mp, n, mip[0]);
- else
- MPN_REDC_2_SEC (this_pp, tp, mp, n, mip);
-#else
- MPN_REDC_1_SEC (this_pp, tp, mp, n, mip[0]);
-#endif
+ for (i = (1 << windowsize) - 2; i > 0; i -= 2)
+ {
+ mpn_local_sqr (tp, ps, n, tp + 2 * n);
+ ps += n;
+ this_pp += n;
+ MPN_REDC_1_SEC (this_pp, tp, mp, n, mip[0]);
+
+ mpn_mul_basecase (tp, this_pp, n, pp + n, n);
+ this_pp += n;
+ MPN_REDC_1_SEC (this_pp, tp, mp, n, mip[0]);
+ }
+ }
+ else
+ {
+ for (i = (1 << windowsize) - 2; i > 0; i -= 2)
+ {
+ mpn_local_sqr (tp, ps, n, tp + 2 * n);
+ ps += n;
+ this_pp += n;
+ MPN_REDC_2_SEC (this_pp, tp, mp, n, mip);
+
+ mpn_mul_basecase (tp, this_pp, n, pp + n, n);
+ this_pp += n;
+ MPN_REDC_2_SEC (this_pp, tp, mp, n, mip);
+ }
}
expbits = getbits (ep, enb, windowsize);
@@ -310,7 +322,6 @@
MPN_REDUCE (rp, tp, mp, n, mip); \
}
-#if WANT_REDC_2
if (BELOW_THRESHOLD (n, REDC_1_TO_REDC_2_THRESHOLD))
{
#undef MPN_REDUCE
@@ -323,23 +334,15 @@
#define MPN_REDUCE(rp,tp,mp,n,mip) MPN_REDC_2_SEC (rp, tp, mp, n, mip)
INNERLOOP;
}
-#else
-#undef MPN_REDUCE
-#define MPN_REDUCE(rp,tp,mp,n,mip) MPN_REDC_1_SEC (rp, tp, mp, n, mip[0])
- INNERLOOP;
-#endif
MPN_COPY (tp, rp, n);
MPN_ZERO (tp + n, n);
-#if WANT_REDC_2
if (BELOW_THRESHOLD (n, REDC_1_TO_REDC_2_THRESHOLD))
MPN_REDC_1_SEC (rp, tp, mp, n, mip[0]);
else
MPN_REDC_2_SEC (rp, tp, mp, n, mip);
-#else
- MPN_REDC_1_SEC (rp, tp, mp, n, mip[0]);
-#endif
+
cnd = mpn_sub_n (tp, rp, mp, n); /* we need just retval */
mpn_cnd_sub_n (!cnd, rp, rp, mp, n);
}
More information about the gmp-commit
mailing list