From 25dbcb277a9dea5f241c0b888a30b9341310d941 Mon Sep 17 00:00:00 2001 From: Andreas Schwab Date: Fri, 25 May 2012 11:57:33 +0200 Subject: Optimize handling of denormals in logb/logbf/logbl --- sysdeps/powerpc/powerpc32/power7/fpu/s_logb.c | 13 +++++++------ sysdeps/powerpc/powerpc32/power7/fpu/s_logbl.c | 8 +++----- 2 files changed, 10 insertions(+), 11 deletions(-) (limited to 'sysdeps/powerpc/powerpc32/power7') diff --git a/sysdeps/powerpc/powerpc32/power7/fpu/s_logb.c b/sysdeps/powerpc/powerpc32/power7/fpu/s_logb.c index fba4822900..87176c34c9 100644 --- a/sysdeps/powerpc/powerpc32/power7/fpu/s_logb.c +++ b/sysdeps/powerpc/powerpc32/power7/fpu/s_logb.c @@ -55,13 +55,14 @@ __logb (double x) /* POSIX specifies that denormal numbers are treated as though they were normalized. */ int32_t lx, ix; - int m1, m2, ma; + int ma; - EXTRACT_WORDS (ix , lx, x); - m1 = (ix == 0) ? 0 : __builtin_clz (ix); - m2 = (lx == 0) ? 0 : __builtin_clz (lx); - ma = (m1 == 0) ? m2 + 32 : m1; - return -1022.0 + (double)(11 - ma); + EXTRACT_WORDS (ix, lx, x); + if (ix == 0) + ma = __builtin_clz (lx) + 32; + else + ma = __builtin_clz (ix); + return (double) (-1023 - (ma - 12)); } /* Test to avoid logb_downward (0.0) == -0.0. */ return ret == -0.0 ? 0.0 : ret; diff --git a/sysdeps/powerpc/powerpc32/power7/fpu/s_logbl.c b/sysdeps/powerpc/powerpc32/power7/fpu/s_logbl.c index 03942ca53d..20c7d4e6e9 100644 --- a/sysdeps/powerpc/powerpc32/power7/fpu/s_logbl.c +++ b/sysdeps/powerpc/powerpc32/power7/fpu/s_logbl.c @@ -56,14 +56,12 @@ __logbl (long double x) return (xh * xh); else if (__builtin_expect (ret == two10m1, 0)) { + /* POSIX specifies that denormal number is treated as + though it were normalized. */ int64_t lx, hx; - int m1, m2, ma; GET_LDOUBLE_WORDS64 (hx, lx, x); - m1 = (hx == 0) ? 0 : __builtin_clzll (hx); - m2 = (lx == 0) ? 0 : __builtin_clzll (lx); - ma = (m1 == 0) ? m2 + 64 : m1; - return -1022.0 + (double)(11 - ma); + return (long double) (-1023 - (__builtin_clzll (hx) - 12)); } /* Test to avoid logb_downward (0.0) == -0.0. */ return ret == -0.0 ? 0.0 : ret; -- cgit v1.2.3