summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbde <bde@FreeBSD.org>2008-01-19 21:37:14 +0000
committerbde <bde@FreeBSD.org>2008-01-19 21:37:14 +0000
commit84998933737bb908831c21cde8c6fc27651bfc34 (patch)
treec3e748c0022c141866c1b2b93edc0bc911915c6e
parent3b6da800e829192b8e9fabd5f6f83c8e9763d517 (diff)
downloadFreeBSD-src-84998933737bb908831c21cde8c6fc27651bfc34.zip
FreeBSD-src-84998933737bb908831c21cde8c6fc27651bfc34.tar.gz
Use STRICT_ASSIGN() for exp2f() and exp2() instead of a volatile
variable hack for exp2f() only. The volatile variable had a surprisingly large cost for exp2f() -- 19 cycles or 15% on i386 in the worst case observed. This is only partly explained by there being several references to the variable, only one of which benefited from it being volatile. Arches that have working assignment are likely to benefit even more from not having any volatile variable. exp2() now has a chance of working with extra precision on i386. exp2() has even more references to the variable, so it would have been pessimized more by simply declaring the variable as volatile. Even the temporary volatile variable for STRICT_ASSIGN costs 5-10% on i386, (A64) so I will change STRICT_ASSIGN() to do an ordinary assignment until i386 defaults to extra precision.
-rw-r--r--lib/msun/src/s_exp2.c2
-rw-r--r--lib/msun/src/s_exp2f.c7
2 files changed, 5 insertions, 4 deletions
diff --git a/lib/msun/src/s_exp2.c b/lib/msun/src/s_exp2.c
index 464e39c..56554f1 100644
--- a/lib/msun/src/s_exp2.c
+++ b/lib/msun/src/s_exp2.c
@@ -364,7 +364,7 @@ exp2(double x)
}
/* Reduce x, computing z, i0, and k. */
- t = x + redux;
+ STRICT_ASSIGN(double, t, x + redux);
GET_LOW_WORD(i0, t);
i0 += TBLSIZE / 2;
k = (i0 >> TBLBITS) << 20;
diff --git a/lib/msun/src/s_exp2f.c b/lib/msun/src/s_exp2f.c
index 0a6142f..db8542c 100644
--- a/lib/msun/src/s_exp2f.c
+++ b/lib/msun/src/s_exp2f.c
@@ -27,6 +27,8 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#include <float.h>
+
#include "math.h"
#include "math_private.h"
@@ -91,8 +93,7 @@ float
exp2f(float x)
{
double tv;
- float r, z;
- volatile float t; /* prevent gcc from using too much precision */
+ float r, t, z;
uint32_t hx, hr, ix, i0;
int32_t k;
@@ -115,7 +116,7 @@ exp2f(float x)
}
/* Reduce x, computing z, i0, and k. */
- t = x + redux;
+ STRICT_ASSIGN(float, t, x + redux);
GET_FLOAT_WORD(i0, t);
i0 += TBLSIZE / 2;
k = (i0 >> TBLBITS) << 23;
OpenPOWER on IntegriCloud