[Gmp-commit] /var/hg/gmp: Rewrite code for limiting mpn_sqr_basecase use.
mercurial at gmplib.org
mercurial at gmplib.org
Sat Feb 11 10:58:00 CET 2012
details: /var/hg/gmp/rev/422bb4bc9ce9
changeset: 14620:422bb4bc9ce9
user: Torbjorn Granlund <tege at gmplib.org>
date: Sat Feb 11 10:57:57 2012 +0100
description:
Rewrite code for limiting mpn_sqr_basecase use.
diffstat:
ChangeLog | 9 +++++++++
mpn/generic/powm_sec.c | 21 ++++++++++-----------
2 files changed, 19 insertions(+), 11 deletions(-)
diffs (77 lines):
diff -r 2cdfeac5befd -r 422bb4bc9ce9 ChangeLog
--- a/ChangeLog Fri Feb 10 22:32:30 2012 +0100
+++ b/ChangeLog Sat Feb 11 10:57:57 2012 +0100
@@ -94,6 +94,15 @@
* tests/cxx/t-cxx11.cc: New file.
* tests/cxx/Makefile.am: Added t-cxx11.
+2012-01-31 Torbjorn Granlund <tege at gmplib.org>
+
+ * mpn/generic/powm_sec.c (SQR_BASECASE_LIM): New name for
+ SQR_BASECASE_MAX.
+ (SQR_BASECASE_LIM, fat variant): Define to read __gmpn_cpuvec.
+ (SQR_BASECASE_LIM, native variant): Define to SQR_TOOM2_THRESHOLD
+ straight, without arithmetic.
+ (mpn_local_sqr): Use BELOW_THRESHOLD as per Marco's suggestion.
+
2012-01-30 Torbjorn Granlund <tege at gmplib.org>
* tests/mpz/t-powm.c: Ensure all sizes are seen.
diff -r 2cdfeac5befd -r 422bb4bc9ce9 mpn/generic/powm_sec.c
--- a/mpn/generic/powm_sec.c Fri Feb 10 22:32:30 2012 +0100
+++ b/mpn/generic/powm_sec.c Sat Feb 11 10:57:57 2012 +0100
@@ -7,7 +7,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, 2008, 2009, 2011 Free Software Foundation, Inc.
+Copyright 2007, 2008, 2009, 2011, 2012 Free Software Foundation, Inc.
This file is part of the GNU MP Library.
@@ -90,7 +90,7 @@
#if ! HAVE_NATIVE_mpn_sqr_basecase
/* The limit of the generic code is SQR_TOOM2_THRESHOLD. */
-#define SQR_BASECASE_MAX SQR_TOOM2_THRESHOLD
+#define SQR_BASECASE_LIM SQR_TOOM2_THRESHOLD
#endif
#if HAVE_NATIVE_mpn_sqr_basecase
@@ -99,20 +99,19 @@
mpn_sqr_basecase, it comes from SQR_TOOM2_THRESHOLD_MAX in the assembly
file. An assembly mpn_sqr_basecase that does not define it, should allow
any size. */
-#define SQR_BASECASE_MAX (SQR_TOOM2_THRESHOLD - 1)
+#define SQR_BASECASE_LIM SQR_TOOM2_THRESHOLD
#endif
#endif
#ifdef WANT_FAT_BINARY
-/* For fat builds, we would need to quantify over all mpn_sqr_basecase limit
- that may appear in __gmpn_cpuvec. This asks for some configure.in hacking.
- For now, define a safe limit which all mpn_sqr_basecase will handle.
- FIXME! */
-#define SQR_BASECASE_MAX 32
+/* For fat builds, we use SQR_TOOM2_THRESHOLD which will expand to a read from
+ __gmpn_cpuvec. Perhaps any possible sqr_basecase.asm allow any size, and we
+ limit the use unnecessarily. We cannot tell, so play it safe. FIXME. */
+#define SQR_BASECASE_LIM SQR_TOOM2_THRESHOLD
#endif
-#ifndef SQR_BASECASE_MAX
-/* If SQR_BASECASE_MAX is now not defined, use mpn_sqr_basecase for any operand
+#ifndef SQR_BASECASE_LIM
+/* If SQR_BASECASE_LIM is now not defined, use mpn_sqr_basecase for any operand
size. */
#define mpn_local_sqr(rp,up,n,tp) mpn_sqr_basecase(rp,up,n)
#else
@@ -126,7 +125,7 @@
ASSERT (n >= 1);
ASSERT (! MPN_OVERLAP_P (rp, 2*n, up, n));
- if (n <= SQR_BASECASE_MAX)
+ if (BELOW_THRESHOLD (n, SQR_BASECASE_LIM))
{
mpn_sqr_basecase (rp, up, n);
return;
More information about the gmp-commit
mailing list