[PATCH] ldbl-128: Refactor modfl snan handling

Paul E. Murphy murphyp@linux.vnet.ibm.com
Mon Aug 8 14:48:00 GMT 2016


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(-)

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 */
-- 
2.4.11



More information about the Libc-alpha mailing list