This is the mail archive of the glibc-cvs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

GNU C Library master sources branch master updated. glibc-2.23-476-g4fea2cd


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, master has been updated
       via  4fea2cda618de1c74959aaec79c020993c34c552 (commit)
      from  c8376f3e07602aaef9cb843bb73cb5f2b860634a (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=4fea2cda618de1c74959aaec79c020993c34c552

commit 4fea2cda618de1c74959aaec79c020993c34c552
Author: Joseph Myers <joseph@codesourcery.com>
Date:   Tue Jun 14 14:56:42 2016 +0000

    Simplify generic fdim implementations.
    
    The generic fdim implementations have unnecessarily complicated code,
    using fpclassify to determine whether the arguments are NaNs,
    subtracting NaNs if so and otherwise subtracting the non-NaN arguments
    if not (x <= y), then using fpclassify on the result to see if it is
    infinite.
    
    This patch simplifies the code.  Instead of handling NaNs separately,
    it suffices to use an unordered comparison with islessequal (x, y) to
    determine whether to return zero, and otherwise NaNs can go through
    the same subtraction as non-NaN arguments; no explicit tests for NaN
    are needed at all.  Then, isinf instead of fpclassify can be used to
    determine whether to set errno (in the normal non-overflow case, only
    one classification will need to occur, unlike the three in the
    previous code, of which two occurred even if returning zero, because
    the result will not be infinite in the normal case).
    
    The resulting logic is essentially the same as that in the powerpc
    version, except that the powerpc version is missing errno setting and
    uses <= not islessequal, so relying on
    <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58684>, the GCC bug that
    unordered comparison instructions are wrongly used on powerpc for
    ordered comparisons.
    
    The compiled code for fdim and fdimf on x86_64 is less than half the
    size of the previous code.
    
    Tested for x86_64.
    
    	* math/s_fdim.c (__fdim): Use islessequal and isinf instead of
    	fpclassify.
    	* math/s_fdimf.c (__fdimf): Likewise.
    	* math/s_fdiml.c (__fdiml): Likewise.

diff --git a/ChangeLog b/ChangeLog
index 495f088..abd8fcb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2016-06-14  Joseph Myers  <joseph@codesourcery.com>
+
+	* math/s_fdim.c (__fdim): Use islessequal and isinf instead of
+	fpclassify.
+	* math/s_fdimf.c (__fdimf): Likewise.
+	* math/s_fdiml.c (__fdiml): Likewise.
+
 2016-06-14  Rajalakshmi Srinivasaraghavan  <raji@linux.vnet.ibm.com>
 
 	* sysdeps/powerpc/powerpc64/multiarch/Makefile:
diff --git a/math/s_fdim.c b/math/s_fdim.c
index b02ed27..8789ca4 100644
--- a/math/s_fdim.c
+++ b/math/s_fdim.c
@@ -23,19 +23,11 @@
 double
 __fdim (double x, double y)
 {
-  int clsx = fpclassify (x);
-  int clsy = fpclassify (y);
-
-  if (clsx == FP_NAN || clsy == FP_NAN)
-    /* Raise invalid flag for signaling but not quiet NaN.  */
-    return x - y;
-
-  if (x <= y)
+  if (islessequal (x, y))
     return 0.0;
 
   double r = x - y;
-  if (fpclassify (r) == FP_INFINITE
-      && clsx != FP_INFINITE && clsy != FP_INFINITE)
+  if (isinf (r) && !isinf (x) && !isinf (y))
     __set_errno (ERANGE);
 
   return r;
diff --git a/math/s_fdimf.c b/math/s_fdimf.c
index b905380..2e8eccf 100644
--- a/math/s_fdimf.c
+++ b/math/s_fdimf.c
@@ -23,19 +23,11 @@
 float
 __fdimf (float x, float y)
 {
-  int clsx = fpclassify (x);
-  int clsy = fpclassify (y);
-
-  if (clsx == FP_NAN || clsy == FP_NAN)
-    /* Raise invalid flag for signaling but not quiet NaN.  */
-    return x - y;
-
-  if (x <= y)
+  if (islessequal (x, y))
     return 0.0f;
 
   float r = x - y;
-  if (fpclassify (r) == FP_INFINITE
-      && clsx != FP_INFINITE && clsy != FP_INFINITE)
+  if (isinf (r) && !isinf (x) && !isinf (y))
     __set_errno (ERANGE);
 
   return r;
diff --git a/math/s_fdiml.c b/math/s_fdiml.c
index df3f1e5..4a1f672 100644
--- a/math/s_fdiml.c
+++ b/math/s_fdiml.c
@@ -23,19 +23,11 @@
 long double
 __fdiml (long double x, long double y)
 {
-  int clsx = fpclassify (x);
-  int clsy = fpclassify (y);
-
-  if (clsx == FP_NAN || clsy == FP_NAN)
-    /* Raise invalid flag for signaling but not quiet NaN.  */
-    return x - y;
-
-  if (x <= y)
+  if (islessequal (x, y))
     return 0.0f;
 
   long double r = x - y;
-  if (fpclassify (r) == FP_INFINITE
-      && clsx != FP_INFINITE && clsy != FP_INFINITE)
+  if (isinf (r) && !isinf (x) && !isinf (y))
     __set_errno (ERANGE);
 
   return r;

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog      |    7 +++++++
 math/s_fdim.c  |   12 ++----------
 math/s_fdimf.c |   12 ++----------
 math/s_fdiml.c |   12 ++----------
 4 files changed, 13 insertions(+), 30 deletions(-)


hooks/post-receive
-- 
GNU C Library master sources


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]