All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] softfloat: Silence signaling NaN when converting to/from float128
@ 2021-05-05 10:49 David Hildenbrand
  2021-05-17 13:57 ` David Hildenbrand
  0 siblings, 1 reply; 2+ messages in thread
From: David Hildenbrand @ 2021-05-05 10:49 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Richard Henderson, Alex Bennée,
	Aurelien Jarno, David Hildenbrand

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



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

* Re: [PATCH v1] softfloat: Silence signaling NaN when converting to/from float128
  2021-05-05 10:49 [PATCH v1] softfloat: Silence signaling NaN when converting to/from float128 David Hildenbrand
@ 2021-05-17 13:57 ` David Hildenbrand
  0 siblings, 0 replies; 2+ messages in thread
From: David Hildenbrand @ 2021-05-17 13:57 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Richard Henderson, Alex Bennée, Aurelien Jarno

On 05.05.21 12:49, David Hildenbrand wrote:
> 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 );
>       }
> 

This problem is also fixed after Richard's rework:

https://lkml.kernel.org/r/20210508014802.892561-1-richard.henderson@linaro.org

-- 
Thanks,

David / dhildenb



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

end of thread, other threads:[~2021-05-17 13:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-05 10:49 [PATCH v1] softfloat: Silence signaling NaN when converting to/from float128 David Hildenbrand
2021-05-17 13:57 ` David Hildenbrand

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.