summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorbde <bde@FreeBSD.org>2008-02-22 10:04:53 +0000
committerbde <bde@FreeBSD.org>2008-02-22 10:04:53 +0000
commit95a5ac17454b24780138372005a56c31d20c7c66 (patch)
treeb484b498788c58528b4353d89e5313e449dcc42e /lib
parent84e9871c8f71a302862c386b464c7e669c83eee4 (diff)
downloadFreeBSD-src-95a5ac17454b24780138372005a56c31d20c7c66.zip
FreeBSD-src-95a5ac17454b24780138372005a56c31d20c7c66.tar.gz
Optimize the fixup for +-0 by using better classification for this case
and by using a table lookup to avoid a branch when this case occurs. On i386, this saves 1-4 cycles out of about 64 for non-large args.
Diffstat (limited to 'lib')
-rw-r--r--lib/msun/src/s_rintl.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/msun/src/s_rintl.c b/lib/msun/src/s_rintl.c
index b2a85b6..7f3b444e 100644
--- a/lib/msun/src/s_rintl.c
+++ b/lib/msun/src/s_rintl.c
@@ -44,6 +44,7 @@ shift[2] = {
#error "Unsupported long double format"
#endif
};
+static const float zero[2] = { 0.0, -0.0 };
long double
rintl(long double x)
@@ -74,7 +75,8 @@ rintl(long double x)
* If the result is +-0, then it must have the same sign as x, but
* the above calculation doesn't always give this. Fix up the sign.
*/
- if (x == 0.0L)
- return (sign ? -0.0L : 0.0L);
+ if (u.bits.exp < BIAS && x == 0.0L)
+ return (zero[sign]);
+
return (x);
}
OpenPOWER on IntegriCloud