From: "Alex Bennée" <alex.bennee@linaro.org>
To: Joseph Myers <joseph@codesourcery.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [PATCH 1/4] softfloat: silence sNaN for conversions to/from floatx80
Date: Fri, 01 May 2020 17:17:14 +0100 [thread overview]
Message-ID: <87k11viq9h.fsf@linaro.org> (raw)
In-Reply-To: <alpine.DEB.2.21.2005010036120.30535@digraph.polyomino.org.uk>
Joseph Myers <joseph@codesourcery.com> writes:
> Conversions between IEEE floating-point formats should convert
> signaling NaNs to quiet NaNs. Most of those in QEMU's softfloat code
> do so, but those for floatx80 fail to. Fix those conversions to
> silence signaling NaNs as well.
I realised we hadn't enabled float-to-float tests for check-softfloat so
with this applied:
--8<---------------cut here---------------start------------->8---
tests/tcg: add check-softfloat-conv-f2f
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
1 file changed, 17 insertions(+), 1 deletion(-)
tests/Makefile.include | 18 +++++++++++++++++-
modified tests/Makefile.include
@@ -687,7 +687,23 @@ test-softfloat = $(call quiet-command, \
(cat $2.out && exit 1;), \
"FLOAT TEST", $2)
-# Conversion Routines:
+# Conversion Routines: Float to Float
+# FIXME: f32_to_f128 (broken)
+check-softfloat-conv-f2f: $(FP_TEST_BIN)
+ $(call test-softfloat, \
+ f16_to_f32 f16_to_f64 \
+ f16_to_extF80 f16_to_f128 \
+ f32_to_f16 f32_to_f64 \
+ f32_to_extF80 \
+ f64_to_f16 f64_to_f32 \
+ f64_to_extF80 f64_to_f128 \
+ extF80_to_f16 extF80_to_f32 \
+ extF80_to_f64 extF80_to_f128 \
+ f128_to_f16 f128_to_f32 \
+ f128_to_f64 f128_to_extF80, \
+ float-to-float)
+
+# Conversion Routines: Float to Float
# FIXME: i32_to_extF80 (broken), i64_to_extF80 (broken)
# ui32_to_f128 (not implemented), extF80_roundToInt (broken)
#
--8<---------------cut here---------------end--------------->8---
I still see some failures for:
f64_to_extF80
f128_to_extF80
(as well as other conversions you've not touched). Ideally we want to
convert the extF80 and f128 code to use the newer FloatParts code which
is pretty robustly tested now. However the trick would be finding a way
to do that that doesn't involve break or regressing the performance for
the f16/32/64 cases. Just using a union causes all sorts of problems.
Anyway I'd settle for fixing the old style code and enabling the tests
we can.
>
> Signed-off-by: Joseph Myers <joseph@codesourcery.com>
> ---
> fpu/softfloat.c | 24 ++++++++++++++++++------
> 1 file changed, 18 insertions(+), 6 deletions(-)
>
> diff --git a/fpu/softfloat.c b/fpu/softfloat.c
> index ae6ba71854..ac116c70b8 100644
> --- a/fpu/softfloat.c
> +++ b/fpu/softfloat.c
> @@ -4498,7 +4498,9 @@ floatx80 float32_to_floatx80(float32 a, float_status *status)
> aSign = extractFloat32Sign( a );
> if ( aExp == 0xFF ) {
> if (aSig) {
> - return commonNaNToFloatx80(float32ToCommonNaN(a, status), status);
> + floatx80 res = commonNaNToFloatx80(float32ToCommonNaN(a, status),
> + status);
> + return floatx80_silence_nan(res, status);
> }
> return packFloatx80(aSign,
> floatx80_infinity_high,
> @@ -5016,7 +5018,9 @@ floatx80 float64_to_floatx80(float64 a, float_status *status)
> aSign = extractFloat64Sign( a );
> if ( aExp == 0x7FF ) {
> if (aSig) {
> - return commonNaNToFloatx80(float64ToCommonNaN(a, status), status);
> + floatx80 res = commonNaNToFloatx80(float64ToCommonNaN(a, status),
> + status);
> + return floatx80_silence_nan(res, status);
> }
> return packFloatx80(aSign,
> floatx80_infinity_high,
> @@ -5618,7 +5622,9 @@ float32 floatx80_to_float32(floatx80 a, float_status *status)
> aSign = extractFloatx80Sign( a );
> if ( aExp == 0x7FFF ) {
> if ( (uint64_t) ( aSig<<1 ) ) {
> - return commonNaNToFloat32(floatx80ToCommonNaN(a, status), status);
> + float32 res = commonNaNToFloat32(floatx80ToCommonNaN(a, status),
> + status);
> + return float32_silence_nan(res, status);
> }
> return packFloat32( aSign, 0xFF, 0 );
> }
> @@ -5650,7 +5656,9 @@ float64 floatx80_to_float64(floatx80 a, float_status *status)
> aSign = extractFloatx80Sign( a );
> if ( aExp == 0x7FFF ) {
> if ( (uint64_t) ( aSig<<1 ) ) {
> - return commonNaNToFloat64(floatx80ToCommonNaN(a, status), status);
> + float64 res = commonNaNToFloat64(floatx80ToCommonNaN(a, status),
> + status);
> + return float64_silence_nan(res, status);
> }
> return packFloat64( aSign, 0x7FF, 0 );
> }
> @@ -5681,7 +5689,9 @@ float128 floatx80_to_float128(floatx80 a, float_status *status)
> aExp = extractFloatx80Exp( a );
> aSign = extractFloatx80Sign( a );
> if ( ( aExp == 0x7FFF ) && (uint64_t) ( aSig<<1 ) ) {
> - return commonNaNToFloat128(floatx80ToCommonNaN(a, status), status);
> + float128 res = commonNaNToFloat128(floatx80ToCommonNaN(a, status),
> + status);
> + return float128_silence_nan(res, status);
> }
> shift128Right( aSig<<1, 0, 16, &zSig0, &zSig1 );
> return packFloat128( aSign, aExp, zSig0, zSig1 );
> @@ -6959,7 +6969,9 @@ floatx80 float128_to_floatx80(float128 a, float_status *status)
> aSign = extractFloat128Sign( a );
> if ( aExp == 0x7FFF ) {
> if ( aSig0 | aSig1 ) {
> - return commonNaNToFloatx80(float128ToCommonNaN(a, status), status);
> + floatx80 res = commonNaNToFloatx80(float128ToCommonNaN(a, status),
> + status);
> + return floatx80_silence_nan(res, status);
> }
> return packFloatx80(aSign, floatx80_infinity_high,
> floatx80_infinity_low);
> --
> 2.17.1
--
Alex Bennée
next prev parent reply other threads:[~2020-05-01 16:23 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-01 0:37 [PATCH 1/4] softfloat: silence sNaN for conversions to/from floatx80 Joseph Myers
2020-05-01 15:45 ` Alex Bennée
2020-05-01 16:17 ` Alex Bennée [this message]
2020-05-01 16:57 ` Richard Henderson
2020-05-01 17:00 ` Joseph Myers
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=87k11viq9h.fsf@linaro.org \
--to=alex.bennee@linaro.org \
--cc=joseph@codesourcery.com \
--cc=qemu-devel@nongnu.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 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.