about summary refs log tree commit diff
path: root/sysdeps/powerpc/powerpc32/fpu/s_nearbyintf.S
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/powerpc/powerpc32/fpu/s_nearbyintf.S')
-rw-r--r--sysdeps/powerpc/powerpc32/fpu/s_nearbyintf.S8
1 files changed, 7 insertions, 1 deletions
diff --git a/sysdeps/powerpc/powerpc32/fpu/s_nearbyintf.S b/sysdeps/powerpc/powerpc32/fpu/s_nearbyintf.S
index 107b035a24..7490e9c6d3 100644
--- a/sysdeps/powerpc/powerpc32/fpu/s_nearbyintf.S
+++ b/sysdeps/powerpc/powerpc32/fpu/s_nearbyintf.S
@@ -48,7 +48,7 @@ ENTRY (__nearbyintf)
 	fabs	fp0,fp1
 	fsub    fp12,fp13,fp13		/* generate 0.0  */
 	fcmpu	cr7,fp0,fp13		/* if (fabs(x) > TWO23 */
-	bgelr	cr7
+	bge	cr7,.L10
 	fcmpu	cr7,fp1,fp12		/* if (x > 0.0 */
 	ble	cr7,L(lessthanzero)
 	mffs	fp11
@@ -67,6 +67,12 @@ L(lessthanzero):
 	fnabs	fp1,fp1			/* if (x == 0.0) */
 	mtfsf	0xff,fp11		/* Restore FE_INEXACT state.  */
 	blr
+.L10:
+	/* Ensure sNaN input is converted to qNaN.  */
+	fcmpu	cr7,fp1,fp1
+	beqlr	cr7
+	fadds	fp1,fp1,fp1
+	blr
 END (__nearbyintf)
 
 weak_alias (__nearbyintf, nearbyintf)