[Gmp-commit] /var/hg/gmp: (MPN_REDC_1, MPN_REDC_1_SEC): Prefer mpn_sbpi1_bdiv...
mercurial at gmplib.org
mercurial at gmplib.org
Wed Nov 20 22:18:51 UTC 2019
details: /var/hg/gmp/rev/e1a085445c8e
changeset: 17979:e1a085445c8e
user: Torbjorn Granlund <tg at gmplib.org>
date: Wed Nov 20 23:16:40 2019 +0100
description:
(MPN_REDC_1, MPN_REDC_1_SEC): Prefer mpn_sbpi1_bdiv_r when it is provided.
diffstat:
mpn/generic/powm.c | 14 +++++++++++++-
mpn/generic/sec_powm.c | 11 ++++++++++-
2 files changed, 23 insertions(+), 2 deletions(-)
diffs (72 lines):
diff -r 3cc19de86f76 -r e1a085445c8e mpn/generic/powm.c
--- a/mpn/generic/powm.c Wed Nov 20 16:44:46 2019 +0100
+++ b/mpn/generic/powm.c Wed Nov 20 23:16:40 2019 +0100
@@ -6,7 +6,7 @@
SAFE TO REACH THEM THROUGH DOCUMENTED INTERFACES. IN FACT, IT IS ALMOST
GUARANTEED THAT THEY WILL CHANGE OR DISAPPEAR IN A FUTURE GNU MP RELEASE.
-Copyright 2007-2012 Free Software Foundation, Inc.
+Copyright 2007-2012, 2019 Free Software Foundation, Inc.
This file is part of the GNU MP Library.
@@ -99,6 +99,17 @@
} while (0)
#undef MPN_REDC_1
+#if HAVE_NATIVE_mpn_sbpi1_bdiv_r
+#define MPN_REDC_1(rp, up, mp, n, invm) \
+ do { \
+ mp_limb_t cy; \
+ cy = mpn_sbpi1_bdiv_r (up, 2 * n, mp, n, invm); \
+ if (cy != 0) \
+ mpn_sub_n (rp, up + n, mp, n); \
+ else \
+ MPN_COPY (rp, up + n, n); \
+ } while (0)
+#else
#define MPN_REDC_1(rp, up, mp, n, invm) \
do { \
mp_limb_t cy; \
@@ -106,6 +117,7 @@
if (cy != 0) \
mpn_sub_n (rp, rp, mp, n); \
} while (0)
+#endif
#undef MPN_REDC_2
#define MPN_REDC_2(rp, up, mp, n, mip) \
diff -r 3cc19de86f76 -r e1a085445c8e mpn/generic/sec_powm.c
--- a/mpn/generic/sec_powm.c Wed Nov 20 16:44:46 2019 +0100
+++ b/mpn/generic/sec_powm.c Wed Nov 20 23:16:40 2019 +0100
@@ -3,7 +3,7 @@
Contributed to the GNU project by Torbjörn Granlund.
-Copyright 2007-2009, 2011-2014, 2018 Free Software Foundation, Inc.
+Copyright 2007-2009, 2011-2014, 2018-2019 Free Software Foundation, Inc.
This file is part of the GNU MP Library.
@@ -63,12 +63,21 @@
#include "longlong.h"
#undef MPN_REDC_1_SEC
+#if HAVE_NATIVE_mpn_sbpi1_bdiv_r
+#define MPN_REDC_1_SEC(rp, up, mp, n, invm) \
+ do { \
+ mp_limb_t cy; \
+ cy = mpn_sbpi1_bdiv_r (up, 2 * n, mp, n, invm); \
+ mpn_cnd_sub_n (cy, rp, up + n, mp, n); \
+ } while (0)
+#else
#define MPN_REDC_1_SEC(rp, up, mp, n, invm) \
do { \
mp_limb_t cy; \
cy = mpn_redc_1 (rp, up, mp, n, invm); \
mpn_cnd_sub_n (cy, rp, rp, mp, n); \
} while (0)
+#endif
#if HAVE_NATIVE_mpn_addmul_2 || HAVE_NATIVE_mpn_redc_2
#undef MPN_REDC_2_SEC
More information about the gmp-commit
mailing list