[Gmp-commit] /home/hgfiles/gmp: Again rework logic for mpn_sqr_basecase size ...

mercurial at gmplib.org mercurial at gmplib.org
Sun Dec 6 18:17:08 CET 2009


details:   /home/hgfiles/gmp/rev/ebb297b863a9
changeset: 12997:ebb297b863a9
user:      Torbjorn Granlund <tege at gmplib.org>
date:      Sun Dec 06 18:16:58 2009 +0100
description:
Again rework logic for mpn_sqr_basecase size limit.

diffstat:

 mpn/generic/powm_sec.c |  20 +++++++++++++++-----
 1 files changed, 15 insertions(+), 5 deletions(-)

diffs (39 lines):

diff -r c5943f0df94f -r ebb297b863a9 mpn/generic/powm_sec.c
--- a/mpn/generic/powm_sec.c	Sun Dec 06 15:01:37 2009 +0100
+++ b/mpn/generic/powm_sec.c	Sun Dec 06 18:16:58 2009 +0100
@@ -81,12 +81,22 @@
 
 #if ! HAVE_NATIVE_mpn_sqr_basecase
 /* The limit of the generic code is SQR_TOOM2_THRESHOLD.  */
-#define SQR_TOOM2_THRESHOLD_MAX SQR_TOOM2_THRESHOLD
+#define SQR_BASECASE_MAX  SQR_TOOM2_THRESHOLD
 #endif
 
-#ifndef SQR_TOOM2_THRESHOLD_MAX
-/* If SQR_TOOM2_THRESHOLD_MAX is not defined, use mpn_sqr_basecase for any
-   operand size.  */
+#if HAVE_NATIVE_mpn_sqr_basecase
+#ifdef TUNE_SQR_TOOM2_MAX
+/* We slightly abuse TUNE_SQR_TOOM2_MAX here.  If it is set for an assembly
+   mpn_sqr_basecase, it comes from SQR_TOOM2_THRESHOLD_MAX in the assembly
+   file.  Assembly mpn_sqr_basecase that do not define it, should allow any
+   size.  */
+#define SQR_BASECASE_MAX  TUNE_SQR_TOOM2_MAX
+#endif
+#endif
+
+#ifndef SQR_BASECASE_MAX
+/* If SQR_BASECASE_MAX is now not defined, use mpn_sqr_basecase for any operand
+   size.  */
 #define mpn_local_sqr_n mpn_sqr_basecase
 #else
 /* Define our own squaring function, which uses mpn_sqr_basecase for its
@@ -99,7 +109,7 @@
   ASSERT (n >= 1);
   ASSERT (! MPN_OVERLAP_P (rp, 2*n, up, n));
 
-  if (n < SQR_TOOM2_THRESHOLD_MAX)
+  if (n < SQR_BASECASE_MAX)
     {
       mpn_sqr_basecase (rp, up, n);
       return;


More information about the gmp-commit mailing list