qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	"Alex Bennée" <alex.bennee@linaro.org>,
	"Aurelien Jarno" <aurelien@aurel32.net>,
	"David Hildenbrand" <david@redhat.com>
Subject: [PATCH v1] softfloat: Silence signaling NaN when converting to/from float128
Date: Wed,  5 May 2021 12:49:52 +0200	[thread overview]
Message-ID: <20210505104952.5632-1-david@redhat.com> (raw)

We forgot to silence the NaN, just as we already do for the other
conversions.

Found by comparing the result of running randomly generated FP instructions
under s390x/tcg and comparing against the result on real HW.

Unfortunately, test cases like f32_to_f128 cannot be unlocked yet as
some expected values (with NaN) are wrongly calculated.

Cc: Aurelien Jarno <aurelien@aurel32.net>
Cc: Peter Maydell <peter.maydell@linaro.org>
Cc: "Alex Bennée" <alex.bennee@linaro.org>
Cc: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: David Hildenbrand <david@redhat.com>
---
 fpu/softfloat.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/fpu/softfloat.c b/fpu/softfloat.c
index 67cfa0fd82..e9f2117a6d 100644
--- a/fpu/softfloat.c
+++ b/fpu/softfloat.c
@@ -4924,7 +4924,9 @@ float128 float32_to_float128(float32 a, float_status *status)
     aSign = extractFloat32Sign( a );
     if ( aExp == 0xFF ) {
         if (aSig) {
-            return commonNaNToFloat128(float32ToCommonNaN(a, status), status);
+            float128 res = commonNaNToFloat128(float32ToCommonNaN(a, status),
+                                               status);
+            return float128_silence_nan(res, status);
         }
         return packFloat128( aSign, 0x7FFF, 0, 0 );
     }
@@ -5229,7 +5231,9 @@ float128 float64_to_float128(float64 a, float_status *status)
     aSign = extractFloat64Sign( a );
     if ( aExp == 0x7FF ) {
         if (aSig) {
-            return commonNaNToFloat128(float64ToCommonNaN(a, status), status);
+            float128 res = commonNaNToFloat128(float64ToCommonNaN(a, status),
+                                               status);
+            return float128_silence_nan(res, status);
         }
         return packFloat128( aSign, 0x7FFF, 0, 0 );
     }
@@ -6665,7 +6669,9 @@ float32 float128_to_float32(float128 a, float_status *status)
     aSign = extractFloat128Sign( a );
     if ( aExp == 0x7FFF ) {
         if ( aSig0 | aSig1 ) {
-            return commonNaNToFloat32(float128ToCommonNaN(a, status), status);
+            float32 res = commonNaNToFloat32(float128ToCommonNaN(a, status),
+                                             status);
+            return float32_silence_nan(res, status);
         }
         return packFloat32( aSign, 0xFF, 0 );
     }
@@ -6699,7 +6705,9 @@ float64 float128_to_float64(float128 a, float_status *status)
     aSign = extractFloat128Sign( a );
     if ( aExp == 0x7FFF ) {
         if ( aSig0 | aSig1 ) {
-            return commonNaNToFloat64(float128ToCommonNaN(a, status), status);
+            float64 res = commonNaNToFloat64(float128ToCommonNaN(a, status),
+                                             status);
+            return float64_silence_nan(res, status);
         }
         return packFloat64( aSign, 0x7FF, 0 );
     }
-- 
2.30.2



             reply	other threads:[~2021-05-05 10:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-05 10:49 David Hildenbrand [this message]
2021-05-17 13:57 ` [PATCH v1] softfloat: Silence signaling NaN when converting to/from float128 David Hildenbrand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210505104952.5632-1-david@redhat.com \
    --to=david@redhat.com \
    --cc=alex.bennee@linaro.org \
    --cc=aurelien@aurel32.net \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 NNTP newsgroup(s).