]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Reduce number of constants in __finite* (bug 15384).
authorJoseph Myers <joseph@codesourcery.com>
Thu, 17 Sep 2015 16:47:14 +0000 (16:47 +0000)
committerJoseph Myers <joseph@codesourcery.com>
Thu, 17 Sep 2015 16:47:14 +0000 (16:47 +0000)
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.

[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.

ChangeLog
NEWS
sysdeps/ieee754/dbl-64/s_finite.c
sysdeps/ieee754/dbl-64/wordsize-64/s_finite.c
sysdeps/ieee754/flt-32/s_finitef.c
sysdeps/ieee754/ldbl-128/s_finitel.c
sysdeps/ieee754/ldbl-128ibm/s_finitel.c

index 5573096bb662cfa0f38287690a4d9aca5067db6a..eec2c829db4498e77aa12476aa8ad37013649b05 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 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.
+
        [BZ #18951]
        * sysdeps/ieee754/dbl-64/e_gamma_r.c (__ieee754_gamma_r): Force
        underflow exception for small results.
diff --git a/NEWS b/NEWS
index cb281865c93e3cc0e503fad80fc577702d93e7a5..46ad3fa12803fc00bfd6032549650eb4cce22bb1 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -9,13 +9,13 @@ Version 2.23
 
 * The following bugs are resolved with this release:
 
-  2542, 2543, 2558, 2898, 4404, 6803, 14341, 14912, 15786, 15918, 16141,
-  16296, 16415, 16517, 16519, 16520, 16521, 16734, 16973, 16985, 17243,
-  17244, 17787, 17905, 18084, 18086, 18240, 18265, 18370, 18421, 18480,
-  18525, 18595, 18610, 18618, 18647, 18661, 18674, 18675, 18681, 18757,
-  18778, 18781, 18787, 18789, 18790, 18795, 18796, 18820, 18823, 18824,
-  18857, 18863, 18870, 18872, 18873, 18875, 18887, 18921, 18951, 18952,
-  18961, 18966, 18967, 18977.
+  2542, 2543, 2558, 2898, 4404, 6803, 14341, 14912, 15384, 15786, 15918,
+  16141, 16296, 16415, 16517, 16519, 16520, 16521, 16734, 16973, 16985,
+  17243, 17244, 17787, 17905, 18084, 18086, 18240, 18265, 18370, 18421,
+  18480, 18525, 18595, 18610, 18618, 18647, 18661, 18674, 18675, 18681,
+  18757, 18778, 18781, 18787, 18789, 18790, 18795, 18796, 18820, 18823,
+  18824, 18857, 18863, 18870, 18872, 18873, 18875, 18887, 18921, 18951,
+  18952, 18961, 18966, 18967, 18977.
 
 * The obsolete header <regexp.h> has been removed.  Programs that require
   this header must be updated to use <regex.h> instead.
index 49986bbde9bebc073869c5d0bc34e55a99640e21..2b0ed504f9be796c507a47071c161bdfdeb74ca6 100644 (file)
@@ -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)
index fcf2e6d5b67a8f1c505fd253f5cd780161970fc1..a155a5e1ef4bdc668d90bd3ae9e865c2159f731f 100644 (file)
@@ -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)
index 4ea270ae073373ba412a7aec16918439869cfed6..4c5b33923514e964d59dfcf23932ee7d812324f7 100644 (file)
@@ -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)
index f862a448ed9ff28f17e6a60d829308e5b4212321..ea8a9ba379276b442d3c861f839bd8c73c935c12 100644 (file)
@@ -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)
index b562ce60b62e2ae21e1e8ed35a60d03ef21234e5..3b9e3de292c19dce13a3fe94df32a578442053d2 100644 (file)
@@ -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;
 }