From: Richard Henderson <richard.henderson@linaro.org>
To: qemu-devel@nongnu.org
Cc: alex.bennee@linaro.org
Subject: [PATCH 03/10] softfloat: Change tininess_before_rounding to bool
Date: Fri, 15 May 2020 12:01:46 -0700 [thread overview]
Message-ID: <20200515190153.6017-4-richard.henderson@linaro.org> (raw)
In-Reply-To: <20200515190153.6017-1-richard.henderson@linaro.org>
Slightly tidies the usage within softfloat.c and the
representation in float_status.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
include/fpu/softfloat-helpers.h | 8 ++---
include/fpu/softfloat-types.h | 8 ++---
fpu/softfloat.c | 54 ++++++++++++---------------------
tests/fp/fp-test.c | 2 +-
4 files changed, 28 insertions(+), 44 deletions(-)
diff --git a/include/fpu/softfloat-helpers.h b/include/fpu/softfloat-helpers.h
index 528d7ebd9f..40d32a6d5d 100644
--- a/include/fpu/softfloat-helpers.h
+++ b/include/fpu/softfloat-helpers.h
@@ -53,9 +53,9 @@ this code that are retained.
#include "fpu/softfloat-types.h"
-static inline void set_float_detect_tininess(int val, float_status *status)
+static inline void set_float_detect_tininess(bool val, float_status *status)
{
- status->float_detect_tininess = val;
+ status->tininess_before_rounding = val;
}
static inline void set_float_rounding_mode(int val, float_status *status)
@@ -94,9 +94,9 @@ static inline void set_snan_bit_is_one(bool val, float_status *status)
status->snan_bit_is_one = val;
}
-static inline int get_float_detect_tininess(float_status *status)
+static inline bool get_float_detect_tininess(float_status *status)
{
- return status->float_detect_tininess;
+ return status->tininess_before_rounding;
}
static inline int get_float_rounding_mode(float_status *status)
diff --git a/include/fpu/softfloat-types.h b/include/fpu/softfloat-types.h
index 619b875df6..874ddd9f93 100644
--- a/include/fpu/softfloat-types.h
+++ b/include/fpu/softfloat-types.h
@@ -116,10 +116,8 @@ typedef struct {
* Software IEC/IEEE floating-point underflow tininess-detection mode.
*/
-enum {
- float_tininess_after_rounding = 0,
- float_tininess_before_rounding = 1
-};
+#define float_tininess_after_rounding false
+#define float_tininess_before_rounding true
/*
*Software IEC/IEEE floating-point rounding mode.
@@ -158,10 +156,10 @@ enum {
*/
typedef struct float_status {
- signed char float_detect_tininess;
signed char float_rounding_mode;
uint8_t float_exception_flags;
signed char floatx80_rounding_precision;
+ bool tininess_before_rounding;
/* should denormalised results go to zero and set the inexact flag? */
bool flush_to_zero;
/* should denormalised inputs go to zero and set the input_denormal flag? */
diff --git a/fpu/softfloat.c b/fpu/softfloat.c
index b741cf5bc3..65d457a548 100644
--- a/fpu/softfloat.c
+++ b/fpu/softfloat.c
@@ -744,8 +744,7 @@ static FloatParts round_canonical(FloatParts p, float_status *s,
p.cls = float_class_zero;
goto do_zero;
} else {
- bool is_tiny = (s->float_detect_tininess
- == float_tininess_before_rounding)
+ bool is_tiny = s->tininess_before_rounding
|| (exp < 0)
|| !((frac + inc) & DECOMPOSED_OVERFLOW_BIT);
@@ -3579,11 +3578,9 @@ static float32 roundAndPackFloat32(bool zSign, int zExp, uint32_t zSig,
float_raise(float_flag_output_denormal, status);
return packFloat32(zSign, 0, 0);
}
- isTiny =
- (status->float_detect_tininess
- == float_tininess_before_rounding)
- || ( zExp < -1 )
- || ( zSig + roundIncrement < 0x80000000 );
+ isTiny = status->tininess_before_rounding
+ || (zExp < -1)
+ || (zSig + roundIncrement < 0x80000000);
shift32RightJamming( zSig, - zExp, &zSig );
zExp = 0;
roundBits = zSig & 0x7F;
@@ -3735,11 +3732,9 @@ static float64 roundAndPackFloat64(bool zSign, int zExp, uint64_t zSig,
float_raise(float_flag_output_denormal, status);
return packFloat64(zSign, 0, 0);
}
- isTiny =
- (status->float_detect_tininess
- == float_tininess_before_rounding)
- || ( zExp < -1 )
- || ( zSig + roundIncrement < UINT64_C(0x8000000000000000) );
+ isTiny = status->tininess_before_rounding
+ || (zExp < -1)
+ || (zSig + roundIncrement < UINT64_C(0x8000000000000000));
shift64RightJamming( zSig, - zExp, &zSig );
zExp = 0;
roundBits = zSig & 0x3FF;
@@ -3878,11 +3873,9 @@ floatx80 roundAndPackFloatx80(int8_t roundingPrecision, bool zSign,
float_raise(float_flag_output_denormal, status);
return packFloatx80(zSign, 0, 0);
}
- isTiny =
- (status->float_detect_tininess
- == float_tininess_before_rounding)
- || ( zExp < 0 )
- || ( zSig0 <= zSig0 + roundIncrement );
+ isTiny = status->tininess_before_rounding
+ || (zExp < 0 )
+ || (zSig0 <= zSig0 + roundIncrement);
shift64RightJamming( zSig0, 1 - zExp, &zSig0 );
zExp = 0;
roundBits = zSig0 & roundMask;
@@ -3956,12 +3949,10 @@ floatx80 roundAndPackFloatx80(int8_t roundingPrecision, bool zSign,
floatx80_infinity_low);
}
if ( zExp <= 0 ) {
- isTiny =
- (status->float_detect_tininess
- == float_tininess_before_rounding)
- || ( zExp < 0 )
- || ! increment
- || ( zSig0 < UINT64_C(0xFFFFFFFFFFFFFFFF) );
+ isTiny = status->tininess_before_rounding
+ || (zExp < 0)
+ || !increment
+ || (zSig0 < UINT64_C(0xFFFFFFFFFFFFFFFF));
shift64ExtraRightJamming( zSig0, zSig1, 1 - zExp, &zSig0, &zSig1 );
zExp = 0;
if (isTiny && zSig1) {
@@ -4237,17 +4228,12 @@ static float128 roundAndPackFloat128(bool zSign, int32_t zExp,
float_raise(float_flag_output_denormal, status);
return packFloat128(zSign, 0, 0, 0);
}
- isTiny =
- (status->float_detect_tininess
- == float_tininess_before_rounding)
- || ( zExp < -1 )
- || ! increment
- || lt128(
- zSig0,
- zSig1,
- UINT64_C(0x0001FFFFFFFFFFFF),
- UINT64_C(0xFFFFFFFFFFFFFFFF)
- );
+ isTiny = status->tininess_before_rounding
+ || (zExp < -1)
+ || !increment
+ || lt128(zSig0, zSig1,
+ UINT64_C(0x0001FFFFFFFFFFFF),
+ UINT64_C(0xFFFFFFFFFFFFFFFF));
shift128ExtraRightJamming(
zSig0, zSig1, zSig2, - zExp, &zSig0, &zSig1, &zSig2 );
zExp = 0;
diff --git a/tests/fp/fp-test.c b/tests/fp/fp-test.c
index 7d0faf2b47..43ef9628c4 100644
--- a/tests/fp/fp-test.c
+++ b/tests/fp/fp-test.c
@@ -989,7 +989,7 @@ static void QEMU_NORETURN run_test(void)
verCases_tininessCode = 0;
slowfloat_detectTininess = tmode;
- qsf.float_detect_tininess = sf_tininess_to_qemu(tmode);
+ qsf.tininess_before_rounding = sf_tininess_to_qemu(tmode);
if (attrs & FUNC_EFF_TININESSMODE ||
((attrs & FUNC_EFF_TININESSMODE_REDUCEDPREC) &&
--
2.20.1
next prev parent reply other threads:[~2020-05-15 19:03 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-15 19:01 [PATCH 00/10] softfloat: misc cleanups Richard Henderson
2020-05-15 19:01 ` [PATCH 01/10] softfloat: Use post test for floatN_mul Richard Henderson
2020-05-19 8:48 ` Alex Bennée
2020-05-15 19:01 ` [PATCH 02/10] softfloat: Replace flag with bool Richard Henderson
2020-05-16 5:27 ` Philippe Mathieu-Daudé
2020-05-19 8:53 ` Alex Bennée
2020-05-15 19:01 ` Richard Henderson [this message]
2020-05-19 8:55 ` [PATCH 03/10] softfloat: Change tininess_before_rounding to bool Alex Bennée
2020-05-15 19:01 ` [PATCH 04/10] softfloat: Name rounding mode enum Richard Henderson
2020-05-16 5:30 ` Philippe Mathieu-Daudé
2020-05-19 9:06 ` Alex Bennée
2020-05-15 19:01 ` [PATCH 05/10] softfloat: Name compare relation enum Richard Henderson
2020-05-16 5:32 ` Philippe Mathieu-Daudé
2020-05-19 9:08 ` Alex Bennée
2020-05-15 19:01 ` [PATCH 06/10] softfloat: Inline float32 compare specializations Richard Henderson
2020-05-19 9:38 ` Alex Bennée
2020-05-15 19:01 ` [PATCH 07/10] softfloat: Inline float64 " Richard Henderson
2020-05-19 9:41 ` Alex Bennée
2020-05-15 19:01 ` [PATCH 08/10] softfloat: Inline float128 " Richard Henderson
2020-05-19 9:41 ` Alex Bennée
2020-05-15 19:01 ` [PATCH 09/10] softfloat: Inline floatx80 " Richard Henderson
2020-05-19 9:41 ` Alex Bennée
2020-05-15 19:01 ` [PATCH 10/10] softfloat: Return bool from all classification predicates Richard Henderson
2020-05-16 5:33 ` Philippe Mathieu-Daudé
2020-05-19 10:10 ` Alex Bennée
2020-05-19 15:47 ` Richard Henderson
2020-05-16 10:58 ` [PATCH 00/10] softfloat: misc cleanups no-reply
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=20200515190153.6017-4-richard.henderson@linaro.org \
--to=richard.henderson@linaro.org \
--cc=alex.bennee@linaro.org \
--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 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).