public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH, PR61219]: Fix sNaN handling in ARM float to double conversion
@ 2014-05-18 21:23 Aurelien Jarno
  2014-05-19  6:08 ` Joey Ye
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Aurelien Jarno @ 2014-05-18 21:23 UTC (permalink / raw)
  To: gcc-patches

On ARM soft-float, the float to double conversion doesn't convert a sNaN
to qNaN as the IEEE Std 754 standard mandates:

"Under default exception handling, any operation signaling an invalid
operation exception and for which a floating-point result is to be
delivered shall deliver a quiet NaN."

Given the soft float ARM code ignores exceptions and always provides a
result, a float to double conversion of a signaling NaN should return a
quiet NaN. Fix this in extendsfdf2.


2014-05-18  Aurelien Jarno  <aurelien@aurel32.net>
       
	PR target/61219
	* config/arm/ieee754-df.S (extendsfdf2): Convert sNaN to qNaN.


Index: libgcc/config/arm/ieee754-df.S
===================================================================
--- libgcc/config/arm/ieee754-df.S	(revision 210588)
+++ libgcc/config/arm/ieee754-df.S	(working copy)
@@ -473,11 +473,15 @@
 	eorne	xh, xh, #0x38000000	@ fixup exponent otherwise.
 	RETc(ne)			@ and return it.
 
-	teq	r2, #0			@ if actually 0
-	do_it	ne, e
-	teqne	r3, #0xff000000		@ or INF or NAN
+	bics	r2, r2, #0xff000000	@ isolate mantissa
+	do_it	eq			@ if 0, that is ZERO or INF,
 	RETc(eq)			@ we are done already.
 
+	teq	r3, #0xff000000		@ check for NAN
+	do_it	eq, t
+	orreq	xh, xh, #0x00080000	@ change to quiet NAN
+	RETc(eq)			@ and return it.
+
 	@ value was denormalized.  We can normalize it now.
 	do_push	{r4, r5, lr}
 	mov	r4, #0x380		@ setup corresponding exponent

-- 
Aurelien Jarno                          GPG: 4096R/1DDD8C9B
aurelien@aurel32.net                 http://www.aurel32.net

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-06-20 22:58 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-18 21:23 [PATCH, PR61219]: Fix sNaN handling in ARM float to double conversion Aurelien Jarno
2014-05-19  6:08 ` Joey Ye
2014-05-19  6:48   ` Aurelien Jarno
2014-06-07 10:54 ` Aurelien Jarno
2014-06-17 22:29 ` Ramana Radhakrishnan
2014-06-20 22:17   ` Aurelien Jarno
2014-06-20 22:58     ` Joseph S. Myers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).