aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/ieee754
diff options
context:
space:
mode:
authorAndreas Schwab <schwab@linux-m68k.org>2012-05-25 11:57:33 +0200
committerAndreas Schwab <schwab@linux-m68k.org>2012-05-26 13:53:22 +0200
commit25dbcb277a9dea5f241c0b888a30b9341310d941 (patch)
tree74c7933f325f44fed6f2f15fd87c59fd4752be37 /sysdeps/ieee754
parentd81dcb356909937b0c8e9c69ff0be27f51aaa07a (diff)
downloadglibc-25dbcb277a9dea5f241c0b888a30b9341310d941.zip
glibc-25dbcb277a9dea5f241c0b888a30b9341310d941.tar.gz
glibc-25dbcb277a9dea5f241c0b888a30b9341310d941.tar.bz2
Optimize handling of denormals in logb/logbf/logbl
Diffstat (limited to 'sysdeps/ieee754')
-rw-r--r--sysdeps/ieee754/dbl-64/s_logb.c10
-rw-r--r--sysdeps/ieee754/dbl-64/wordsize-64/s_logb.c4
-rw-r--r--sysdeps/ieee754/flt-32/s_logbf.c3
-rw-r--r--sysdeps/ieee754/ldbl-128/s_logbl.c10
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/s_logbl.c7
-rw-r--r--sysdeps/ieee754/ldbl-96/s_logbl.c10
6 files changed, 23 insertions, 21 deletions
diff --git a/sysdeps/ieee754/dbl-64/s_logb.c b/sysdeps/ieee754/dbl-64/s_logb.c
index baa35e1..17aa94b 100644
--- a/sysdeps/ieee754/dbl-64/s_logb.c
+++ b/sysdeps/ieee754/dbl-64/s_logb.c
@@ -34,10 +34,12 @@ __logb (double x)
{
/* POSIX specifies that denormal number is treated as
though it were normalized. */
- int m1 = (ix == 0) ? 0 : __builtin_clz (ix);
- int m2 = (lx == 0) ? 0 : __builtin_clz (lx);
- int ma = (m1 == 0) ? m2 + 32 : m1;
- return -1022.0 + (double)(11 - ma);
+ int ma;
+ if (ix == 0)
+ ma = __builtin_clz (lx) + 32;
+ else
+ ma = __builtin_clz (ix);
+ rix -= ma - 12;
}
return (double) (rix - 1023);
}
diff --git a/sysdeps/ieee754/dbl-64/wordsize-64/s_logb.c b/sysdeps/ieee754/dbl-64/wordsize-64/s_logb.c
index 185dd05..40b8888 100644
--- a/sysdeps/ieee754/dbl-64/wordsize-64/s_logb.c
+++ b/sysdeps/ieee754/dbl-64/wordsize-64/s_logb.c
@@ -36,8 +36,8 @@ __logb (double x)
return x * x;
if (__builtin_expect (ex == 0, 0))
{
- int m = (ix == 0) ? 0 : __builtin_clzll (ix);
- return -1022.0 + (double)(11 -m);
+ int m = __builtin_clzll (ix);
+ ex -= m - 12;
}
return (double) (ex - 1023);
}
diff --git a/sysdeps/ieee754/flt-32/s_logbf.c b/sysdeps/ieee754/flt-32/s_logbf.c
index 025c70d..e2b3aaa 100644
--- a/sysdeps/ieee754/flt-32/s_logbf.c
+++ b/sysdeps/ieee754/flt-32/s_logbf.c
@@ -31,8 +31,7 @@ __logbf (float x)
{
/* POSIX specifies that denormal number is treated as
though it were normalized. */
- int m = (ix == 0) ? 0 : __builtin_clz (ix);
- return -126.0 + (float)(8 - m);
+ rix -= __builtin_clz (ix) - 9;
}
return (float) (rix - 127);
}
diff --git a/sysdeps/ieee754/ldbl-128/s_logbl.c b/sysdeps/ieee754/ldbl-128/s_logbl.c
index cf6003e..3ba67b7 100644
--- a/sysdeps/ieee754/ldbl-128/s_logbl.c
+++ b/sysdeps/ieee754/ldbl-128/s_logbl.c
@@ -41,10 +41,12 @@ __logbl (long double x)
{
/* POSIX specifies that denormal number is treated as
though it were normalized. */
- int m1 = (hx == 0) ? 0 : __builtin_clzll (hx);
- int m2 = (lx == 0) ? 0 : __builtin_clzll (lx);
- int ma = (m1 == 0) ? m2 + 64 : m1;
- return -16382.0 + (long double)(15 - ma);
+ int ma;
+ if (hx == 0)
+ ma = __builtin_clzll (lx) + 64;
+ else
+ ma = __builtin_clzll (hx);
+ ex -= ma - 16;
}
return (long double) (ex - 16383);
}
diff --git a/sysdeps/ieee754/ldbl-128ibm/s_logbl.c b/sysdeps/ieee754/ldbl-128ibm/s_logbl.c
index 678b6ca..92ce2c1 100644
--- a/sysdeps/ieee754/ldbl-128ibm/s_logbl.c
+++ b/sysdeps/ieee754/ldbl-128ibm/s_logbl.c
@@ -30,7 +30,7 @@ __logbl (long double x)
GET_LDOUBLE_WORDS64 (hx, lx, x);
hx &= 0x7fffffffffffffffLL; /* high |x| */
- if ((hx | (lx & 0x7fffffffffffffffLL)) == 0)
+ if (hx == 0)
return -1.0 / fabs (x);
if (hx >= 0x7ff0000000000000LL)
return x * x;
@@ -38,10 +38,7 @@ __logbl (long double x)
{
/* POSIX specifies that denormal number is treated as
though it were normalized. */
- int m1 = (hx == 0) ? 0 : __builtin_clzll (hx);
- int m2 = (lx == 0) ? 0 : __builtin_clzll (lx);
- int ma = (m1 == 0) ? m2 + 64 : m1;
- return -1022.0 + (long double)(11 - ma);
+ rhx -= __builtin_clzll (hx) - 12;
}
return (long double) (rhx - 1023);
}
diff --git a/sysdeps/ieee754/ldbl-96/s_logbl.c b/sysdeps/ieee754/ldbl-96/s_logbl.c
index d8ad4bc..4289be1 100644
--- a/sysdeps/ieee754/ldbl-96/s_logbl.c
+++ b/sysdeps/ieee754/ldbl-96/s_logbl.c
@@ -38,10 +38,12 @@ __logbl (long double x)
{
/* POSIX specifies that denormal number is treated as
though it were normalized. */
- int m1 = (ix == 0) ? 0 : __builtin_clz (ix);
- int m2 = (lx == 0) ? 0 : __builtin_clz (lx);
- int ma = (m1 == 0) ? m2 + 32 : m1;
- return -16382.0 - (long double)(ma);
+ int ma;
+ if (ix == 0)
+ ma = __builtin_clz (lx) + 32;
+ else
+ ma = __builtin_clz (ix);
+ es -= ma - 1;
}
return (long double) (es - 16383);
}