summaryrefslogtreecommitdiff
path: root/tune
diff options
context:
space:
mode:
authorMarco Bodrato <bodrato@mail.dm.unipi.it>2019-11-16 08:48:59 +0100
committerMarco Bodrato <bodrato@mail.dm.unipi.it>2019-11-16 08:48:59 +0100
commitcc5da06284277c69529776c0a30b0f98bd969c11 (patch)
treef02c5620bdcd346495e0a18840c59b20ed560362 /tune
parent811421c50eedea16d2d8675c606a013055a1525d (diff)
downloadgmp-cc5da06284277c69529776c0a30b0f98bd969c11.tar.gz
tune: Small optimisations to recent changes.
Diffstat (limited to 'tune')
-rw-r--r--tune/common.c2
-rw-r--r--tune/speed.c2
-rw-r--r--tune/speed.h18
3 files changed, 11 insertions, 11 deletions
diff --git a/tune/common.c b/tune/common.c
index e803d046e..c8b17fced 100644
--- a/tune/common.c
+++ b/tune/common.c
@@ -1,6 +1,6 @@
/* Shared speed subroutines.
-Copyright 1999-2006, 2008-2017 Free Software Foundation, Inc.
+Copyright 1999-2006, 2008-2017, 2019 Free Software Foundation, Inc.
This file is part of the GNU MP Library.
diff --git a/tune/speed.c b/tune/speed.c
index b9fe23cad..24a51a985 100644
--- a/tune/speed.c
+++ b/tune/speed.c
@@ -1,6 +1,6 @@
/* Speed measuring program.
-Copyright 1999-2003, 2005, 2006, 2008-2018 Free Software Foundation, Inc.
+Copyright 1999-2003, 2005, 2006, 2008-2019 Free Software Foundation, Inc.
This file is part of the GNU MP Library.
diff --git a/tune/speed.h b/tune/speed.h
index 41170e901..f23bacb1e 100644
--- a/tune/speed.h
+++ b/tune/speed.h
@@ -1,6 +1,7 @@
/* Header for speed and threshold things.
-Copyright 1999-2003, 2005, 2006, 2008-2016 Free Software Foundation, Inc.
+Copyright 1999-2003, 2005, 2006, 2008-2017, 2019 Free Software
+Foundation, Inc.
This file is part of the GNU MP Library.
@@ -3478,17 +3479,16 @@ int speed_routine_count_zeros_setup (struct speed_params *, mp_ptr, int, int);
Worst case is multiple prime factors larger than trial div limit. */
#define SPEED_ROUTINE_MPN_PERFECT_POWER(function) \
{ \
- mpz_t r, p; \
+ mpz_t r; \
unsigned i, power; \
double t; \
\
SPEED_RESTRICT_COND (s->size >= 10); \
\
- mpz_init_set_ui (p, (1 << 16) + 1); /* larger than 1000th prime */ \
- mpz_init_set_ui (r, (1 << 17) - 1); \
+ mpz_init (r); \
power = s->size * GMP_NUMB_BITS / 17; \
- mpz_pow_ui(r, r, power - 1); \
- mpz_mul(r, r, p); \
+ mpz_ui_pow_ui(r, (1 << 17) - 1, power - 1); \
+ mpz_mul_ui(r, r, (1 << 16) + 1); /* larger than 1000th prime */ \
\
speed_starttime (); \
i = s->reps; \
@@ -3498,7 +3498,6 @@ int speed_routine_count_zeros_setup (struct speed_params *, mp_ptr, int, int);
t = speed_endtime (); \
\
mpz_clear (r); \
- mpz_clear (p); \
return t; \
}
@@ -3506,12 +3505,13 @@ int speed_routine_count_zeros_setup (struct speed_params *, mp_ptr, int, int);
#define SPEED_ROUTINE_MPN_PERFECT_SQUARE(function) \
{ \
mpz_t r; \
- unsigned i, power; \
+ unsigned i; \
double t; \
\
SPEED_RESTRICT_COND (s->size >= 2); \
mpz_init_set_n (r, s->xp, s->size / 2); \
- mpz_pow_ui(r, r, 2); \
+ mpz_setbit (r, s->size * GMP_NUMB_BITS / 2 - 1); \
+ mpz_mul (r, r, r); \
\
speed_starttime (); \
i = s->reps; \