This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Reduce number of constants in __finite* (bug 15384) [committed]
- From: Joseph Myers <joseph at codesourcery dot com>
- To: <libc-alpha at sourceware dot org>
- Date: Thu, 17 Sep 2015 16:48:26 +0000
- Subject: Reduce number of constants in __finite* (bug 15384) [committed]
- Authentication-results: sourceware.org; auth=none
Bug 15384 notes that in __finite, two different constants are used
that could be the same constant (the result only depends on the
exponent of the floating-point representation), and that using the
same constant is better for architectures where constants need loading
from a constant pool. This patch implements that change.
Tested for x86_64, mips64 and powerpc. Committed.
2015-09-17 Joseph Myers <joseph@codesourcery.com>
[BZ #15384]
* sysdeps/ieee754/dbl-64/s_finite.c (FINITE): Use same constant as
bit-mask as in subtraction.
* sysdeps/ieee754/dbl-64/wordsize-64/s_finite.c (__finite):
Likewise.
* sysdeps/ieee754/flt-32/s_finitef.c (FINITEF): Likewise.
* sysdeps/ieee754/ldbl-128/s_finitel.c (__finitel): Likewise.
* sysdeps/ieee754/ldbl-128ibm/s_finitel.c (__finitel): Likewise.
diff --git a/sysdeps/ieee754/dbl-64/s_finite.c b/sysdeps/ieee754/dbl-64/s_finite.c
index 49986bb..2b0ed50 100644
--- a/sysdeps/ieee754/dbl-64/s_finite.c
+++ b/sysdeps/ieee754/dbl-64/s_finite.c
@@ -32,7 +32,7 @@ int FINITE(double x)
{
int32_t hx;
GET_HIGH_WORD (hx, x);
- return (int) ((u_int32_t) ((hx & 0x7fffffff) - 0x7ff00000) >> 31);
+ return (int) ((u_int32_t) ((hx & 0x7ff00000) - 0x7ff00000) >> 31);
}
hidden_def (__finite)
weak_alias (__finite, finite)
diff --git a/sysdeps/ieee754/dbl-64/wordsize-64/s_finite.c b/sysdeps/ieee754/dbl-64/wordsize-64/s_finite.c
index fcf2e6d..a155a5e 100644
--- a/sysdeps/ieee754/dbl-64/wordsize-64/s_finite.c
+++ b/sysdeps/ieee754/dbl-64/wordsize-64/s_finite.c
@@ -24,7 +24,7 @@ __finite(double x)
{
int64_t lx;
EXTRACT_WORDS64(lx,x);
- return (int)((uint64_t)((lx&INT64_C(0x7fffffffffffffff))-INT64_C(0x7ff0000000000000))>>63);
+ return (int)((uint64_t)((lx&INT64_C(0x7ff0000000000000))-INT64_C(0x7ff0000000000000))>>63);
}
hidden_def (__finite)
weak_alias (__finite, finite)
diff --git a/sysdeps/ieee754/flt-32/s_finitef.c b/sysdeps/ieee754/flt-32/s_finitef.c
index 4ea270a..4c5b339 100644
--- a/sysdeps/ieee754/flt-32/s_finitef.c
+++ b/sysdeps/ieee754/flt-32/s_finitef.c
@@ -35,7 +35,7 @@ int FINITEF(float x)
{
int32_t ix;
GET_FLOAT_WORD(ix,x);
- return (int)((u_int32_t)((ix&0x7fffffff)-0x7f800000)>>31);
+ return (int)((u_int32_t)((ix&0x7f800000)-0x7f800000)>>31);
}
hidden_def (__finitef)
weak_alias (__finitef, finitef)
diff --git a/sysdeps/ieee754/ldbl-128/s_finitel.c b/sysdeps/ieee754/ldbl-128/s_finitel.c
index f862a44..ea8a9ba 100644
--- a/sysdeps/ieee754/ldbl-128/s_finitel.c
+++ b/sysdeps/ieee754/ldbl-128/s_finitel.c
@@ -29,7 +29,7 @@ int __finitel(long double x)
{
int64_t hx;
GET_LDOUBLE_MSW64(hx,x);
- return (int)((u_int64_t)((hx&0x7fffffffffffffffLL)
+ return (int)((u_int64_t)((hx&0x7fff000000000000LL)
-0x7fff000000000000LL)>>63);
}
hidden_def (__finitel)
diff --git a/sysdeps/ieee754/ldbl-128ibm/s_finitel.c b/sysdeps/ieee754/ldbl-128ibm/s_finitel.c
index b562ce6..3b9e3de 100644
--- a/sysdeps/ieee754/ldbl-128ibm/s_finitel.c
+++ b/sysdeps/ieee754/ldbl-128ibm/s_finitel.c
@@ -34,7 +34,7 @@ ___finitel (long double x)
xhi = ldbl_high (x);
EXTRACT_WORDS64 (hx, xhi);
- hx &= 0x7fffffffffffffffLL;
+ hx &= 0x7ff0000000000000LL;
hx -= 0x7ff0000000000000LL;
return hx >> 63;
}
--
Joseph S. Myers
joseph@codesourcery.com