diff mbox

[COMMITTED] PowerPC: Fix modf/modff optimization return sign

Message ID 531B56ED.7020408@linux.vnet.ibm.com
State Committed
Delegated to: Adhemerval Zanella Netto
Headers show

Commit Message

Adhemerval Zanella Netto March 8, 2014, 5:44 p.m. UTC
I just pushed the above patch that fixes a wrong sign in next test for non-default
modf/modff rounding modes.

---

 ChangeLog                             | 6 ++++++
 sysdeps/powerpc/power5+/fpu/s_modf.c  | 4 ++--
 sysdeps/powerpc/power5+/fpu/s_modff.c | 4 ++--
 3 files changed, 10 insertions(+), 4 deletions(-)
diff mbox

Patch

diff --git a/ChangeLog b/ChangeLog
index 4071f08..5266177 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@ 
+2014-03-03  Adhemerval Zanella  <azanella@linux.vnet.ibm.com>
+
+	* sysdeps/powerpc/power5+/fpu/s_modf.c (__modf): Fix to return correct
+	sign in non default rounding modes.
+	* sysdeps/powerpc/power5+/fpu/s_modff.c (__modff): Likewise.
+
 2014-03-08  Joseph Myers  <joseph@codesourcery.com>
 
 	* math/libm-test.inc (ALL_RM_TEST): New macro.
diff --git a/sysdeps/powerpc/power5+/fpu/s_modf.c b/sysdeps/powerpc/power5+/fpu/s_modf.c
index eb469f7..06da3ac 100644
--- a/sysdeps/powerpc/power5+/fpu/s_modf.c
+++ b/sysdeps/powerpc/power5+/fpu/s_modf.c
@@ -36,12 +36,12 @@  __modf (double x, double *iptr)
   if (x >= 0.0)
     {
       *iptr = __floor (x);
-      return (x - *iptr);
+      return __copysign (x - *iptr, x);
     }
   else
     {
       *iptr = __ceil (x);
-      return (x - *iptr);
+      return __copysign (x - *iptr, x);
     }
 }
 weak_alias (__modf, modf)
diff --git a/sysdeps/powerpc/power5+/fpu/s_modff.c b/sysdeps/powerpc/power5+/fpu/s_modff.c
index e4fe857..af17bec 100644
--- a/sysdeps/powerpc/power5+/fpu/s_modff.c
+++ b/sysdeps/powerpc/power5+/fpu/s_modff.c
@@ -35,12 +35,12 @@  __modff (float x, float *iptr)
   if (x >= 0.0)
     {
       *iptr = __floorf (x);
-      return (x - *iptr);
+      return __copysignf (x - *iptr, x);
     }
   else
     {
       *iptr = __ceilf (x);
-      return (x - *iptr);
+      return __copysignf (x - *iptr, x);
     }
 }
 weak_alias (__modff, modff)