diff options
author | Andreas Schwab <schwab@linux-m68k.org> | 2012-05-25 11:57:33 +0200 |
---|---|---|
committer | Andreas Schwab <schwab@linux-m68k.org> | 2012-05-26 13:53:22 +0200 |
commit | 25dbcb277a9dea5f241c0b888a30b9341310d941 (patch) | |
tree | 74c7933f325f44fed6f2f15fd87c59fd4752be37 /sysdeps/powerpc/powerpc32 | |
parent | d81dcb356909937b0c8e9c69ff0be27f51aaa07a (diff) | |
download | glibc-25dbcb277a9dea5f241c0b888a30b9341310d941.tar.gz glibc-25dbcb277a9dea5f241c0b888a30b9341310d941.tar.xz glibc-25dbcb277a9dea5f241c0b888a30b9341310d941.zip |
Optimize handling of denormals in logb/logbf/logbl
Diffstat (limited to 'sysdeps/powerpc/powerpc32')
-rw-r--r-- | sysdeps/powerpc/powerpc32/power7/fpu/s_logb.c | 13 | ||||
-rw-r--r-- | sysdeps/powerpc/powerpc32/power7/fpu/s_logbl.c | 8 |
2 files changed, 10 insertions, 11 deletions
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; |