SPARC: fix nearbyint on sNaN input
nearbyint and nearbyintf should not trigger inexact exceptions, but should still trigger an invalid exception for a sNaN input. The SPARC specific implementations of these functions save the FSR at the beginning of the function and restore it at the end to not trigger an inexact exception. This however doesn't work for an sNaN input which need to trigger an invalid exception. Fix that by adding a fcmp instruction using the input value before saving FSR, so that an invalid exception is triggered for a sNaN input. This fixes the math/test-nearbyint-except test on SPARC. Changelog: * sparc/sparc32/sparcv9/fpu/s_nearbyint.S (__nearbyint): Trigger an invalid exception for a sNaN input. * sparc/sparc32/sparcv9/fpu/s_nearbyintf.S (__nearbyintf): Likewise. * sparc/sparc32/sparcv9/fpu/multiarch/s_nearbyint-vis3.S (__nearbyint_vis3): Likewise * sparc/sparc32/sparcv9/fpu/multiarch/s_nearbyintf-vis3.S (__nearbyintf_vis3): Likewise * sparc/sparc64/fpu/s_nearbyint.S (__nearbyint): Likewise. * sparc/sparc64/fpu/s_nearbyintf.S (__nearbyintf): Likewise. * sparc/sparc64/fpu/multiarch/s_nearbyint-vis3.S (__nearbyint_vis3): Likewise. * sparc/sparc64/fpu/multiarch/s_nearbyintf-vis3.S (__nearbyintf_vis3): Likewise.
This commit is contained in:
parent
f43cb35c9b
commit
2cbec36566
16
ChangeLog
16
ChangeLog
@ -1,3 +1,19 @@
|
||||
2016-07-01 Aurelien Jarno <aurelien@aurel32.net>
|
||||
|
||||
* sparc/sparc32/sparcv9/fpu/s_nearbyint.S (__nearbyint): Trigger an
|
||||
invalid exception for a sNaN input.
|
||||
* sparc/sparc32/sparcv9/fpu/s_nearbyintf.S (__nearbyintf): Likewise.
|
||||
* sparc/sparc32/sparcv9/fpu/multiarch/s_nearbyint-vis3.S
|
||||
(__nearbyint_vis3): Likewise
|
||||
* sparc/sparc32/sparcv9/fpu/multiarch/s_nearbyintf-vis3.S
|
||||
(__nearbyintf_vis3): Likewise
|
||||
* sparc/sparc64/fpu/s_nearbyint.S (__nearbyint): Likewise.
|
||||
* sparc/sparc64/fpu/s_nearbyintf.S (__nearbyintf): Likewise.
|
||||
* sparc/sparc64/fpu/multiarch/s_nearbyint-vis3.S (__nearbyint_vis3):
|
||||
Likewise.
|
||||
* sparc/sparc64/fpu/multiarch/s_nearbyintf-vis3.S (__nearbyintf_vis3):
|
||||
Likewise.
|
||||
|
||||
2016-07-01 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
[BZ #20139]
|
||||
|
@ -36,6 +36,7 @@
|
||||
#define SIGN_BIT %f12 /* -0.0 */
|
||||
|
||||
ENTRY (__nearbyint_vis3)
|
||||
fcmpd %fcc3, %f0, %f0 /* Check for sNaN */
|
||||
st %fsr, [%sp + 88]
|
||||
sethi %hi(TWO_FIFTYTWO), %o2
|
||||
sethi %hi(0xf8003e0), %o5
|
||||
|
@ -35,6 +35,7 @@
|
||||
#define SIGN_BIT %f12 /* -0.0 */
|
||||
|
||||
ENTRY (__nearbyintf_vis3)
|
||||
fcmps %fcc3, %f1, %f1 /* Check for sNaN */
|
||||
st %fsr, [%sp + 88]
|
||||
movwtos %o0, %f1
|
||||
sethi %hi(TWO_TWENTYTHREE), %o2
|
||||
|
@ -36,6 +36,7 @@
|
||||
#define SIGN_BIT %f12 /* -0.0 */
|
||||
|
||||
ENTRY (__nearbyint)
|
||||
fcmpd %fcc3, %f0, %f0 /* Check for sNaN */
|
||||
st %fsr, [%sp + 88]
|
||||
sethi %hi(TWO_FIFTYTWO), %o2
|
||||
sethi %hi(0xf8003e0), %o5
|
||||
|
@ -35,6 +35,7 @@
|
||||
#define SIGN_BIT %f12 /* -0.0 */
|
||||
|
||||
ENTRY (__nearbyintf)
|
||||
fcmps %fcc3, %f1, %f1 /* Check for sNaN */
|
||||
st %fsr, [%sp + 88]
|
||||
st %o0, [%sp + 68]
|
||||
sethi %hi(TWO_TWENTYTHREE), %o2
|
||||
|
@ -35,6 +35,7 @@
|
||||
#define SIGN_BIT %f12 /* -0.0 */
|
||||
|
||||
ENTRY (__nearbyint_vis3)
|
||||
fcmpd %fcc3, %f0, %f0 /* Check for sNaN */
|
||||
stx %fsr, [%sp + STACK_BIAS + 144]
|
||||
sethi %hi(TWO_FIFTYTWO), %o2
|
||||
sllx %o2, 32, %o2
|
||||
|
@ -35,6 +35,7 @@
|
||||
#define SIGN_BIT %f12 /* -0.0 */
|
||||
|
||||
ENTRY (__nearbyintf_vis3)
|
||||
fcmps %fcc3, %f1, %f1 /* Check for sNaN */
|
||||
stx %fsr, [%sp + STACK_BIAS + 144]
|
||||
sethi %hi(0xf8003e0), %o5
|
||||
sethi %hi(TWO_TWENTYTHREE), %o2
|
||||
|
@ -35,6 +35,7 @@
|
||||
#define SIGN_BIT %f12 /* -0.0 */
|
||||
|
||||
ENTRY (__nearbyint)
|
||||
fcmpd %fcc3, %f0, %f0 /* Check for sNaN */
|
||||
stx %fsr, [%sp + STACK_BIAS + 144]
|
||||
sethi %hi(TWO_FIFTYTWO), %o2
|
||||
sllx %o2, 32, %o2
|
||||
|
@ -35,6 +35,7 @@
|
||||
#define SIGN_BIT %f12 /* -0.0 */
|
||||
|
||||
ENTRY (__nearbyintf)
|
||||
fcmps %fcc3, %f1, %f1 /* Check for sNaN */
|
||||
stx %fsr, [%sp + STACK_BIAS + 144]
|
||||
sethi %hi(0xf8003e0), %o5
|
||||
sethi %hi(TWO_TWENTYTHREE), %o2
|
||||
|
Loading…
Reference in New Issue
Block a user