aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/powerpc/powerpc32/fpu
diff options
context:
space:
mode:
authorAdhemerval Zanella <azanella@linux.vnet.ibm.com>2014-04-06 14:50:11 -0500
committerAdhemerval Zanella <azanella@linux.vnet.ibm.com>2014-04-06 14:58:05 -0500
commit8bd70862e11023e7f827f240a5a214f847ae982d (patch)
treec7ed6614a24d974afaf8b416da0fc373052a5911 /sysdeps/powerpc/powerpc32/fpu
parentd42f3448a7af9c55f2193450964772c7c2a0d29b (diff)
downloadglibc-8bd70862e11023e7f827f240a5a214f847ae982d.tar
glibc-8bd70862e11023e7f827f240a5a214f847ae982d.tar.gz
glibc-8bd70862e11023e7f827f240a5a214f847ae982d.tar.bz2
glibc-8bd70862e11023e7f827f240a5a214f847ae982d.zip
PowerPC: Fix nearbyint/nearbyintf result for FE_DOWNWARD
This patch fixes the powerpc32 optimized nearbyint/nearbyintf bogus results for FE_DOWNWARD rounding mode. This is due wrong instructions sequence used in the rounding calculation (two subtractions instead of adition and a subtraction). Fixes BZ#16815.
Diffstat (limited to 'sysdeps/powerpc/powerpc32/fpu')
-rw-r--r--sysdeps/powerpc/powerpc32/fpu/s_nearbyint.S10
-rw-r--r--sysdeps/powerpc/powerpc32/fpu/s_nearbyintf.S11
2 files changed, 11 insertions, 10 deletions
diff --git a/sysdeps/powerpc/powerpc32/fpu/s_nearbyint.S b/sysdeps/powerpc/powerpc32/fpu/s_nearbyint.S
index 2734738d4d..05ab40ecb5 100644
--- a/sysdeps/powerpc/powerpc32/fpu/s_nearbyint.S
+++ b/sysdeps/powerpc/powerpc32/fpu/s_nearbyint.S
@@ -53,17 +53,17 @@ ENTRY (__nearbyint)
fcmpu cr7,fp1,fp12 /* if (x > 0.0 */
ble cr7,L(lessthanzero)
mtfsb0 4*cr7+lt /* Disable FE_INEXACT exception */
- fadd fp0,fp1,fp13 /* x += TWO52 */
- fsub fp1,fp0,fp13 /* x -= TWO52 */
+ fadd fp1,fp1,fp13 /* x += TWO52 */
+ fsub fp1,fp1,fp13 /* x -= TWO52 */
fabs fp1,fp1 /* if (x == 0.0 */
mtfsb0 4*cr1+eq /* Clear any FE_INEXACT exception */
blr
L(lessthanzero):
bgelr cr7
mtfsb0 4*cr7+lt /* Disable FE_INEXACT exception */
- fsub fp0,fp13,fp1 /* x -= TWO52 */
- fsub fp0,fp0,fp13 /* x += TWO52 */
- fneg fp1,fp0 /* if (x == 0.0) */
+ fsub fp1,fp1,fp13 /* x -= TWO52 */
+ fadd fp1,fp1,fp13 /* x += TWO52 */
+ fnabs fp1,fp1 /* if (x == 0.0) */
mtfsb0 4*cr1+eq /* Clear any FE_INEXACT exception */
blr
END (__nearbyint)
diff --git a/sysdeps/powerpc/powerpc32/fpu/s_nearbyintf.S b/sysdeps/powerpc/powerpc32/fpu/s_nearbyintf.S
index 11bdc77370..7449a5f9b7 100644
--- a/sysdeps/powerpc/powerpc32/fpu/s_nearbyintf.S
+++ b/sysdeps/powerpc/powerpc32/fpu/s_nearbyintf.S
@@ -52,16 +52,17 @@ ENTRY (__nearbyintf)
fcmpu cr7,fp1,fp12 /* if (x > 0.0 */
ble cr7,L(lessthanzero)
mtfsb0 4*cr7+lt /* Disable FE_INEXACT exception */
- fadds fp0,fp1,fp13 /* x += TWO23 */
- fsubs fp1,fp0,fp13 /* x -= TWO23 */
+ fadds fp1,fp1,fp13 /* x += TWO23 */
+ fsubs fp1,fp1,fp13 /* x -= TWO23 */
+ fabs fp1,fp1 /* if (x == 0.0) */
mtfsb0 4*cr1+eq /* Clear any FE_INEXACT exception */
blr
L(lessthanzero):
bgelr cr7
mtfsb0 4*cr7+lt /* Disable FE_INEXACT exception */
- fsubs fp0,fp13,fp1 /* x -= TWO23 */
- fsubs fp0,fp0,fp13 /* x += TWO23 */
- fneg fp1,fp0 /* if (x == 0.0) */
+ fsubs fp1,fp1,fp13 /* x -= TWO23 */
+ fadds fp1,fp1,fp13 /* x += TWO23 */
+ fnabs fp1,fp1 /* if (x == 0.0) */
mtfsb0 4*cr1+eq /* Clear any FE_INEXACT exception */
blr
END (__nearbyintf)