diff options
author | bde <bde@FreeBSD.org> | 2008-02-19 12:54:14 +0000 |
---|---|---|
committer | bde <bde@FreeBSD.org> | 2008-02-19 12:54:14 +0000 |
commit | e508bf1279c21ed622306af43844139988972c81 (patch) | |
tree | c1e215f064d40ea6af92470afa770861ca6a89d2 /lib | |
parent | 2aa5a61fd32c181b70181233740e601e8d759d8d (diff) | |
download | FreeBSD-src-e508bf1279c21ed622306af43844139988972c81.zip FreeBSD-src-e508bf1279c21ed622306af43844139988972c81.tar.gz |
Rearrange the polynomial evaluation for better parallelism. This
saves an average of about 8 cycles or 5% on A64 (amd64 and i386 --
more in cycles but about the same percentage on i386, and more with
old versions of gcc) with good CFLAGS and some parallelism in the
caller. As usual, it takes a couple more multiplications so it will
be slower on old machines.
Convert to __FBSDID().
Diffstat (limited to 'lib')
-rw-r--r-- | lib/msun/src/k_cos.c | 8 | ||||
-rw-r--r-- | lib/msun/src/k_sin.c | 10 |
2 files changed, 9 insertions, 9 deletions
diff --git a/lib/msun/src/k_cos.c b/lib/msun/src/k_cos.c index 9933bf3..c4702e6 100644 --- a/lib/msun/src/k_cos.c +++ b/lib/msun/src/k_cos.c @@ -11,9 +11,8 @@ * ==================================================== */ -#ifndef lint -static char rcsid[] = "$FreeBSD$"; -#endif +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); /* * __kernel_cos( x, y ) @@ -72,7 +71,8 @@ __kernel_cos(double x, double y) double hz,z,r,w; z = x*x; - r = z*(C1+z*(C2+z*(C3+z*(C4+z*(C5+z*C6))))); + w = z*z; + r = z*(C1+z*(C2+z*C3)) + w*w*(C4+z*(C5+z*C6)); hz = 0.5*z; w = one-hz; return w + (((one-w)-hz) + (z*r-x*y)); diff --git a/lib/msun/src/k_sin.c b/lib/msun/src/k_sin.c index fe2a56c..12ee8c1 100644 --- a/lib/msun/src/k_sin.c +++ b/lib/msun/src/k_sin.c @@ -11,9 +11,8 @@ * ==================================================== */ -#ifndef lint -static char rcsid[] = "$FreeBSD$"; -#endif +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); /* __kernel_sin( x, y, iy) * kernel sin function on ~[-pi/4, pi/4] (except on -0), pi/4 ~ 0.7854 @@ -60,11 +59,12 @@ S6 = 1.58969099521155010221e-10; /* 0x3DE5D93A, 0x5ACFD57C */ double __kernel_sin(double x, double y, int iy) { - double z,r,v; + double z,r,v,w; z = x*x; + w = z*z; + r = S2+z*(S3+z*S4) + z*w*(S5+z*S6); v = z*x; - r = S2+z*(S3+z*(S4+z*(S5+z*S6))); if(iy==0) return x+v*(S1+z*r); else return x-((z*(half*y-v*r)-y)-v*S1); } |