diff options
author | bde <bde@FreeBSD.org> | 2008-02-18 14:02:12 +0000 |
---|---|---|
committer | bde <bde@FreeBSD.org> | 2008-02-18 14:02:12 +0000 |
commit | ad78d666213a592bddae82c25e993dd47786dcef (patch) | |
tree | 390f2485d24a844d41ef64862adc9c01ce71db04 /lib/msun | |
parent | 6c809a426ade64ce82f2f4480682bc1c520f6a2d (diff) | |
download | FreeBSD-src-ad78d666213a592bddae82c25e993dd47786dcef.zip FreeBSD-src-ad78d666213a592bddae82c25e993dd47786dcef.tar.gz |
Inline __ieee754__rem_pio2(). With gcc4-2, this gives an average
optimization of about 10% for cos(x), sin(x) and tan(x) on
|x| < 2**19*pi/2. We didn't do this before because __ieee754__rem_pio2()
is too large and complicated for gcc-3.3 to inline very well. We don't
do this for float precision because it interferes with optimization
of the usual (?) case (|x| < 9pi/4) which is manually inlined for float
precision only.
This has some rough edges:
- some static data is duplicated unnecessarily. There isn't much after
the recent move of large tables to k_rem_pio2.c, and some static data
is duplicated to good affect (all the data static const, so that the
compiler can evaluate expressions like 2*pio2 at compile time and
generate even more static data for the constant for this).
- extern inline is used (for the same reason as in previous inlining of
k_cosf.c etc.), but C99 apparently doesn't allow extern inline
functions with static data, and gcc will eventually warn about this.
Convert to __FBSDID().
Indent __ieee754_rem_pio2()'s declaration consistently (its style was
made inconsistent with fdlibm a while ago, so complete this).
Fix __ieee754_rem_pio2()'s return type to match its prototype. Someone
changed too many ints to int32_t's when fixing the assumption that all
ints are int32_t's.
Diffstat (limited to 'lib/msun')
-rw-r--r-- | lib/msun/src/e_rem_pio2.c | 11 | ||||
-rw-r--r-- | lib/msun/src/s_cos.c | 7 | ||||
-rw-r--r-- | lib/msun/src/s_sin.c | 7 | ||||
-rw-r--r-- | lib/msun/src/s_tan.c | 7 |
4 files changed, 19 insertions, 13 deletions
diff --git a/lib/msun/src/e_rem_pio2.c b/lib/msun/src/e_rem_pio2.c index caf391d..5467744 100644 --- a/lib/msun/src/e_rem_pio2.c +++ b/lib/msun/src/e_rem_pio2.c @@ -12,9 +12,8 @@ * */ -#ifndef lint -static char rcsid[] = "$FreeBSD$"; -#endif +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); /* __ieee754_rem_pio2(x,y) * @@ -56,7 +55,11 @@ pio2_2t = 2.02226624879595063154e-21, /* 0x3BA3198A, 0x2E037073 */ pio2_3 = 2.02226624871116645580e-21, /* 0x3BA3198A, 0x2E000000 */ pio2_3t = 8.47842766036889956997e-32; /* 0x397B839A, 0x252049C1 */ - int32_t __ieee754_rem_pio2(double x, double *y) +#ifdef INLINE_REM_PIO2 +extern inline +#endif +int +__ieee754_rem_pio2(double x, double *y) { double z,w,t,r,fn; double tx[3]; diff --git a/lib/msun/src/s_cos.c b/lib/msun/src/s_cos.c index b2fae38..496027c 100644 --- a/lib/msun/src/s_cos.c +++ b/lib/msun/src/s_cos.c @@ -10,9 +10,8 @@ * ==================================================== */ -#ifndef lint -static char rcsid[] = "$FreeBSD$"; -#endif +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); /* cos(x) * Return cosine function of x. @@ -48,7 +47,9 @@ static char rcsid[] = "$FreeBSD$"; #include <float.h> #include "math.h" +#define INLINE_REM_PIO2 #include "math_private.h" +#include "e_rem_pio2.c" double cos(double x) diff --git a/lib/msun/src/s_sin.c b/lib/msun/src/s_sin.c index 7cd3877..f6ed2b5 100644 --- a/lib/msun/src/s_sin.c +++ b/lib/msun/src/s_sin.c @@ -10,9 +10,8 @@ * ==================================================== */ -#ifndef lint -static char rcsid[] = "$FreeBSD$"; -#endif +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); /* sin(x) * Return sine function of x. @@ -48,7 +47,9 @@ static char rcsid[] = "$FreeBSD$"; #include <float.h> #include "math.h" +#define INLINE_REM_PIO2 #include "math_private.h" +#include "e_rem_pio2.c" double sin(double x) diff --git a/lib/msun/src/s_tan.c b/lib/msun/src/s_tan.c index d9d37b6..bd62789 100644 --- a/lib/msun/src/s_tan.c +++ b/lib/msun/src/s_tan.c @@ -10,9 +10,8 @@ * ==================================================== */ -#ifndef lint -static char rcsid[] = "$FreeBSD$"; -#endif +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); /* tan(x) * Return tangent function of x. @@ -47,7 +46,9 @@ static char rcsid[] = "$FreeBSD$"; #include <float.h> #include "math.h" +#define INLINE_REM_PIO2 #include "math_private.h" +#include "e_rem_pio2.c" double tan(double x) |