ldbl-128: Refactor modfl snan handling
diff mbox

Message ID fa6c5987-a9c9-a7ef-6006-29058b95f8f4@linux.vnet.ibm.com
State New
Headers show

Commit Message

Paul E. Murphy Aug. 8, 2016, 2:48 p.m. UTC
This causes a test failure on float128/ppc64le
as the multiplication is optimized away.  This
updates it to use conversions similar to other
files.

Tested on s390x to verify no new test failures
occur.  This also reduced the code size a little
bit too.

	* sysdeps/ieee754/ldbl-128/s_modfl.c (one): Removed.
	(__modfl): Use more compiler friendly mechanism
	to quiet an snan.
---
 sysdeps/ieee754/ldbl-128/s_modfl.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

Comments

Joseph Myers Aug. 8, 2016, 3:20 p.m. UTC | #1
On Mon, 8 Aug 2016, Paul E. Murphy wrote:

> This causes a test failure on float128/ppc64le
> as the multiplication is optimized away.  This
> updates it to use conversions similar to other
> files.

This patch is not relative to current glibc.  You'll also need to explain 
why the

# These files quiet sNaNs in a way that is optimized away without
# -fsignaling-nans.
CFLAGS-s_modf.c += -fsignaling-nans
CFLAGS-s_modff.c += -fsignaling-nans
CFLAGS-s_modfl.c += -fsignaling-nans

in math/Makefile isn't working, as it is for all the similar 
implementations and other architectures.
Paul E. Murphy Aug. 8, 2016, 3:50 p.m. UTC | #2
On 08/08/2016 10:20 AM, Joseph Myers wrote:
> On Mon, 8 Aug 2016, Paul E. Murphy wrote:
> 
>> This causes a test failure on float128/ppc64le
>> as the multiplication is optimized away.  This
>> updates it to use conversions similar to other
>> files.
> 
> This patch is not relative to current glibc.  You'll also need to explain 
> why the
> 
> # These files quiet sNaNs in a way that is optimized away without
> # -fsignaling-nans.
> CFLAGS-s_modf.c += -fsignaling-nans
> CFLAGS-s_modff.c += -fsignaling-nans
> CFLAGS-s_modfl.c += -fsignaling-nans
> 
> in math/Makefile isn't working, as it is for all the similar 
> implementations and other architectures.
> 

And, I missed that little bit of makefile.  Thank you for
pointing it out.  I'll drop the patch for now.


Is there a practical, reusable mechanism to apply a
set of CFLAGS to a list of objects derived from a make
variable without using eval?  Florian raised this issue
earlier and received no feedback.

Likewise, the same question applies to my proposed
patches to refactor the _Complex wrappers.
Joseph Myers Aug. 8, 2016, 4:41 p.m. UTC | #3
On Mon, 8 Aug 2016, Paul E. Murphy wrote:

> Is there a practical, reusable mechanism to apply a
> set of CFLAGS to a list of objects derived from a make
> variable without using eval?  Florian raised this issue
> earlier and received no feedback.

I have no advice on that question.

Patch
diff mbox

diff --git a/sysdeps/ieee754/ldbl-128/s_modfl.c b/sysdeps/ieee754/ldbl-128/s_modfl.c
index adb1ca6..05bcc81 100644
--- a/sysdeps/ieee754/ldbl-128/s_modfl.c
+++ b/sysdeps/ieee754/ldbl-128/s_modfl.c
@@ -30,8 +30,6 @@  static char rcsid[] = "$NetBSD: $";
 #include <math.h>
 #include <math_private.h>
 
-static const ldouble_t one = 1.0;
-
 ldouble_t __modfl(ldouble_t x, ldouble_t *iptr)
 {
 	int64_t i0,i1,j0;
@@ -56,14 +54,15 @@  ldouble_t __modfl(ldouble_t x, ldouble_t *iptr)
 		}
 	    }
 	} else if (j0>111) {		/* no fraction part */
-	    *iptr = x*one;
 	    /* We must handle NaNs separately.  */
 	    if (j0 == 0x4000 && ((i0 & 0x0000ffffffffffffLL) | i1))
 	      {
-		*iptr = x+x;
-		return x+x;
+		/* Coerce x and iptr into qnans.  */
+		*iptr = x + x;
+		return *iptr;
 	      }
 	    /* return +-0 */
+	    *iptr = x;
 	    SET_LDOUBLE_WORDS64(x,i0&0x8000000000000000ULL,0);
 	    return x;
 	} else {			/* fraction part in low x */