From: Adhemerval Zanella Date: Sat, 8 Mar 2014 17:24:32 +0000 (-0600) Subject: PowerPC: Fix modf/modff optimization return sign X-Git-Tag: glibc-2.20~776 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=54b46a4b3efd179ccbbf8e342e64391e2b590f1b;p=thirdparty%2Fglibc.git PowerPC: Fix modf/modff optimization return sign This patch fix the optimized powerpc-fpu modf/modff implementation when using in non-default rounding mode where the zero sign is not as expected. It fixes the libm testsuite tests modf_downward (0) == 0.00000000000000000000e+00 modf_downward (20) == 0.00000000000000000000e+00 modf_downward (21) == 0.00000000000000000000e+00 Where the sign returned was negative. --- diff --git a/ChangeLog b/ChangeLog index 4071f087d18..526617720f7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2014-03-03 Adhemerval Zanella + + * 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 * 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 eb469f7647c..06da3ac8091 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 e4fe857d293..af17becf131 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)