aboutsummaryrefslogtreecommitdiff
path: root/lib/msun
diff options
context:
space:
mode:
authorBruce Evans <bde@FreeBSD.org>2008-02-22 18:43:23 +0000
committerBruce Evans <bde@FreeBSD.org>2008-02-22 18:43:23 +0000
commitdbf10e45c40b8749286a16cadd5ddc0695ecc3e1 (patch)
treec685d7ecf2d6bb5820cc55706947c63ce7813007 /lib/msun
parent7c1b5e7953bbfb8e6b55f176b3ccaaf92d0c52fb (diff)
downloadsrc-dbf10e45c40b8749286a16cadd5ddc0695ecc3e1.tar.gz
src-dbf10e45c40b8749286a16cadd5ddc0695ecc3e1.zip
Avoid using FP-to-integer conversion for !(amd64 || i386) too. Use the
FP-to-FP method to round to an integer on all arches, and convert this to an int using FP-to-integer conversion iff irint() is not available. This is cleaner and works well on at least ia64, where it saves 20-30 cycles or about 10% on average for 9Pi/4 < |x| <= 32pi/2 (should be similar up to 2**19pi/2, but I only tested the smaller range). After the previous commit to e_rem_pio2.c removed the "quick check no cancellation" non-optimization, the result of the FP-to-integer conversion is not needed so early, so using irint() became a much smaller optimization than when it was committed. An earlier commit message said that cos, cosf, sin and sinf were equally fast on amd64 and i386 except for cos and sin on i386. Actually, cos and sin on amd64 are equally fast to cosf and sinf on i386 (~88 cycles), while cosf and sinf on amd64 are not quite equally slow to cos and sin on i386 (average 115 cycles with more variance).
Notes
Notes: svn path=/head/; revision=176467
Diffstat (limited to 'lib/msun')
-rw-r--r--lib/msun/src/e_rem_pio2.c5
-rw-r--r--lib/msun/src/e_rem_pio2f.c5
2 files changed, 4 insertions, 6 deletions
diff --git a/lib/msun/src/e_rem_pio2.c b/lib/msun/src/e_rem_pio2.c
index 708b8822d99c..fc951259eda8 100644
--- a/lib/msun/src/e_rem_pio2.c
+++ b/lib/msun/src/e_rem_pio2.c
@@ -128,14 +128,13 @@ __ieee754_rem_pio2(double x, double *y)
if(ix<=0x413921fb) { /* |x| ~<= 2^19*(pi/2), medium size */
medium:
t = fabs(x);
-#ifdef HAVE_EFFICIENT_IRINT
/* Use a specialized rint() to get fn. Assume round-to-nearest. */
STRICT_ASSIGN(double,fn,t*invpio2+0x1.8p52);
fn = fn-0x1.8p52;
+#ifdef HAVE_EFFICIENT_IRINT
n = irint(fn);
#else
- n = (int32_t) (t*invpio2+half);
- fn = (double)n;
+ n = (int32_t)fn;
#endif
r = t-fn*pio2_1;
w = fn*pio2_1t; /* 1st round good to 85 bit */
diff --git a/lib/msun/src/e_rem_pio2f.c b/lib/msun/src/e_rem_pio2f.c
index c487ab8cdf89..2ed10db4bf47 100644
--- a/lib/msun/src/e_rem_pio2f.c
+++ b/lib/msun/src/e_rem_pio2f.c
@@ -54,14 +54,13 @@ __ieee754_rem_pio2f(float x, float *y)
/* 33+53 bit pi is good enough for medium size */
if(ix<=0x49490f80) { /* |x| ~<= 2^19*(pi/2), medium size */
t = fabsf(x);
-#ifdef HAVE_EFFICIENT_IRINT
/* Use a specialized rint() to get fn. Assume round-to-nearest. */
STRICT_ASSIGN(double,fn,t*invpio2+0x1.8p52);
fn = fn-0x1.8p52;
+#ifdef HAVE_EFFICIENT_IRINT
n = irint(fn);
#else
- n = (int32_t) (t*invpio2+half);
- fn = (double)n;
+ n = (int32_t)fn;
#endif
r = t-fn*pio2_1;
w = fn*pio2_1t;