From: Michael Morrell <mmorrell@tachyum.com>
To: Richard Henderson <richard.henderson@linaro.org>,
"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Cc: "alex.bennee@linaro.org" <alex.bennee@linaro.org>
Subject: RE: [PATCH 03/11] softfloat: Introduce float_flag_inorm_denormal
Date: Fri, 28 May 2021 17:41:12 +0000 [thread overview]
Message-ID: <44a76e8c6504461cbd4dc5752f0d443b@tachyum.com> (raw)
In-Reply-To: <20210527041405.391567-4-richard.henderson@linaro.org>
I'm probably missing something, but why do we need both "float_flag_inorm_denormal" and "float_flag_iflush_denormal"?
Couldn't the code that sets these flags set just a single flag for all denormal inputs and the code that checks these flags check that single flag
combined with the "flush_inputs_to_zero" flag to accomplish what the two separate "input denormal" flags do?
Michael
-----Original Message-----
From: Richard Henderson <richard.henderson@linaro.org>
Sent: Wednesday, May 26, 2021 9:14 PM
To: qemu-devel@nongnu.org
Cc: Michael Morrell <mmorrell@tachyum.com>; alex.bennee@linaro.org
Subject: [PATCH 03/11] softfloat: Introduce float_flag_inorm_denormal
Create a new exception flag for reporting input denormals that are not flushed to zero, they are normalized and treated as normal numbers.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
include/fpu/softfloat-types.h | 15 ++++---
fpu/softfloat.c | 84 +++++++++++------------------------
fpu/softfloat-parts.c.inc | 1 +
3 files changed, 36 insertions(+), 64 deletions(-)
diff --git a/include/fpu/softfloat-types.h b/include/fpu/softfloat-types.h index e2d70ff556..174100e50e 100644
--- a/include/fpu/softfloat-types.h
+++ b/include/fpu/softfloat-types.h
@@ -143,13 +143,14 @@ typedef enum __attribute__((__packed__)) {
*/
enum {
- float_flag_invalid = 1,
- float_flag_divbyzero = 4,
- float_flag_overflow = 8,
- float_flag_underflow = 16,
- float_flag_inexact = 32,
- float_flag_iflush_denormal = 64,
- float_flag_oflush_denormal = 128
+ float_flag_invalid = 0x0001,
+ float_flag_divbyzero = 0x0002,
+ float_flag_overflow = 0x0004,
+ float_flag_underflow = 0x0008,
+ float_flag_inexact = 0x0010,
+ float_flag_inorm_denormal = 0x0020, /* denormal input, normalized */
+ float_flag_iflush_denormal = 0x0040, /* denormal input, flushed to zero */
+ float_flag_oflush_denormal = 0x0080, /* denormal result, flushed
+ to zero */
};
/*
diff --git a/fpu/softfloat.c b/fpu/softfloat.c index cb077cf111..e54cdb274d 100644
--- a/fpu/softfloat.c
+++ b/fpu/softfloat.c
@@ -126,61 +126,23 @@ this code that are retained.
* denormal/inf/NaN; (2) when operands are not guaranteed to lead to a 0 result
* and the result is < the minimum normal.
*/
-#define GEN_INPUT_FLUSH__NOCHECK(name, soft_t) \
+
+#define GEN_INPUT_FLUSH(name, soft_t) \
static inline void name(soft_t *a, float_status *s) \
{ \
if (unlikely(soft_t ## _is_denormal(*a))) { \
- *a = soft_t ## _set_sign(soft_t ## _zero, \
- soft_t ## _is_neg(*a)); \
- float_raise(float_flag_iflush_denormal, s); \
+ if (s->flush_inputs_to_zero) { \
+ *a = soft_t ## _set_sign(0, soft_t ## _is_neg(*a)); \
+ float_raise(float_flag_iflush_denormal, s); \
+ } else { \
+ float_raise(float_flag_inorm_denormal, s); \
+ } \
} \
}
-GEN_INPUT_FLUSH__NOCHECK(float32_input_flush__nocheck, float32) -GEN_INPUT_FLUSH__NOCHECK(float64_input_flush__nocheck, float64) -#undef GEN_INPUT_FLUSH__NOCHECK
-
-#define GEN_INPUT_FLUSH1(name, soft_t) \
- static inline void name(soft_t *a, float_status *s) \
- { \
- if (likely(!s->flush_inputs_to_zero)) { \
- return; \
- } \
- soft_t ## _input_flush__nocheck(a, s); \
- }
-
-GEN_INPUT_FLUSH1(float32_input_flush1, float32) -GEN_INPUT_FLUSH1(float64_input_flush1, float64) -#undef GEN_INPUT_FLUSH1
-
-#define GEN_INPUT_FLUSH2(name, soft_t) \
- static inline void name(soft_t *a, soft_t *b, float_status *s) \
- { \
- if (likely(!s->flush_inputs_to_zero)) { \
- return; \
- } \
- soft_t ## _input_flush__nocheck(a, s); \
- soft_t ## _input_flush__nocheck(b, s); \
- }
-
-GEN_INPUT_FLUSH2(float32_input_flush2, float32) -GEN_INPUT_FLUSH2(float64_input_flush2, float64) -#undef GEN_INPUT_FLUSH2
-
-#define GEN_INPUT_FLUSH3(name, soft_t) \
- static inline void name(soft_t *a, soft_t *b, soft_t *c, float_status *s) \
- { \
- if (likely(!s->flush_inputs_to_zero)) { \
- return; \
- } \
- soft_t ## _input_flush__nocheck(a, s); \
- soft_t ## _input_flush__nocheck(b, s); \
- soft_t ## _input_flush__nocheck(c, s); \
- }
-
-GEN_INPUT_FLUSH3(float32_input_flush3, float32) -GEN_INPUT_FLUSH3(float64_input_flush3, float64) -#undef GEN_INPUT_FLUSH3
+GEN_INPUT_FLUSH(float32_input_flush, float32)
+GEN_INPUT_FLUSH(float64_input_flush, float64) #undef GEN_INPUT_FLUSH
/*
* Choose whether to use fpclassify or float32/64_* primitives in the generated @@ -353,7 +315,8 @@ float32_gen2(float32 xa, float32 xb, float_status *s,
goto soft;
}
- float32_input_flush2(&ua.s, &ub.s, s);
+ float32_input_flush(&ua.s, s);
+ float32_input_flush(&ub.s, s);
if (unlikely(!pre(ua, ub))) {
goto soft;
}
@@ -384,7 +347,8 @@ float64_gen2(float64 xa, float64 xb, float_status *s,
goto soft;
}
- float64_input_flush2(&ua.s, &ub.s, s);
+ float64_input_flush(&ua.s, s);
+ float64_input_flush(&ub.s, s);
if (unlikely(!pre(ua, ub))) {
goto soft;
}
@@ -2161,7 +2125,9 @@ float32_muladd(float32 xa, float32 xb, float32 xc, int flags, float_status *s)
goto soft;
}
- float32_input_flush3(&ua.s, &ub.s, &uc.s, s);
+ float32_input_flush(&ua.s, s);
+ float32_input_flush(&ub.s, s);
+ float32_input_flush(&uc.s, s);
if (unlikely(!f32_is_zon3(ua, ub, uc))) {
goto soft;
}
@@ -2232,7 +2198,9 @@ float64_muladd(float64 xa, float64 xb, float64 xc, int flags, float_status *s)
goto soft;
}
- float64_input_flush3(&ua.s, &ub.s, &uc.s, s);
+ float64_input_flush(&ua.s, s);
+ float64_input_flush(&ub.s, s);
+ float64_input_flush(&uc.s, s);
if (unlikely(!f64_is_zon3(ua, ub, uc))) {
goto soft;
}
@@ -3988,7 +3956,8 @@ float32_hs_compare(float32 xa, float32 xb, float_status *s, bool is_quiet)
goto soft;
}
- float32_input_flush2(&ua.s, &ub.s, s);
+ float32_input_flush(&ua.s, s);
+ float32_input_flush(&ub.s, s);
if (isgreaterequal(ua.h, ub.h)) {
if (isgreater(ua.h, ub.h)) {
return float_relation_greater; @@ -4038,7 +4007,8 @@ float64_hs_compare(float64 xa, float64 xb, float_status *s, bool is_quiet)
goto soft;
}
- float64_input_flush2(&ua.s, &ub.s, s);
+ float64_input_flush(&ua.s, s);
+ float64_input_flush(&ub.s, s);
if (isgreaterequal(ua.h, ub.h)) {
if (isgreater(ua.h, ub.h)) {
return float_relation_greater; @@ -4230,7 +4200,7 @@ float32 QEMU_FLATTEN float32_sqrt(float32 xa, float_status *s)
goto soft;
}
- float32_input_flush1(&ua.s, s);
+ float32_input_flush(&ua.s, s);
if (QEMU_HARDFLOAT_1F32_USE_FP) {
if (unlikely(!(fpclassify(ua.h) == FP_NORMAL ||
fpclassify(ua.h) == FP_ZERO) || @@ -4257,7 +4227,7 @@ float64 QEMU_FLATTEN float64_sqrt(float64 xa, float_status *s)
goto soft;
}
- float64_input_flush1(&ua.s, s);
+ float64_input_flush(&ua.s, s);
if (QEMU_HARDFLOAT_1F64_USE_FP) {
if (unlikely(!(fpclassify(ua.h) == FP_NORMAL ||
fpclassify(ua.h) == FP_ZERO) || diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc index 72e2b24539..16d4425419 100644
--- a/fpu/softfloat-parts.c.inc
+++ b/fpu/softfloat-parts.c.inc
@@ -119,6 +119,7 @@ static void partsN(canonicalize)(FloatPartsN *p, float_status *status,
int shift = frac_normalize(p);
p->cls = float_class_normal;
p->exp = fmt->frac_shift - fmt->exp_bias - shift + 1;
+ float_raise(float_flag_inorm_denormal, status);
}
} else if (likely(p->exp < fmt->exp_max) || fmt->arm_althp) {
p->cls = float_class_normal;
--
2.25.1
next prev parent reply other threads:[~2021-05-28 17:43 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-27 4:13 [PATCH 00/11] softfloat: Improve denormal handling Richard Henderson
2021-05-27 4:13 ` [PATCH 01/11] softfloat: Rename float_flag_input_denormal to float_flag_iflush_denormal Richard Henderson
2021-06-07 15:16 ` Alex Bennée
2021-06-19 15:08 ` Philippe Mathieu-Daudé
2021-05-27 4:13 ` [PATCH 02/11] softfloat: Rename float_flag_output_denormal to float_flag_oflush_denormal Richard Henderson
2021-06-07 15:16 ` Alex Bennée
2021-06-19 15:08 ` Philippe Mathieu-Daudé
2021-05-27 4:13 ` [PATCH 03/11] softfloat: Introduce float_flag_inorm_denormal Richard Henderson
2021-05-28 17:41 ` Michael Morrell [this message]
2021-05-29 15:21 ` Richard Henderson
2021-07-14 16:44 ` Michael Morrell
2021-07-14 16:57 ` Richard Henderson
2021-07-14 17:50 ` Michael Morrell
2022-01-12 0:02 ` Michael Morrell
2021-06-07 15:35 ` Alex Bennée
2021-06-07 16:28 ` Alex Bennée
2021-06-07 16:41 ` Richard Henderson
2021-06-07 17:19 ` Alex Bennée
2021-06-07 20:52 ` Richard Henderson
2021-05-27 4:13 ` [PATCH 04/11] softfloat: Introduce float_flag_result_denormal Richard Henderson
2021-06-07 16:30 ` Alex Bennée
2021-06-19 15:10 ` Philippe Mathieu-Daudé
2021-05-27 4:13 ` [PATCH 05/11] target/i386: Use float_flag_inorm_denormal Richard Henderson
2021-06-19 18:41 ` Richard Henderson
2021-05-27 4:14 ` [PATCH 06/11] target/rx: Handle the FPSW.DN bit in helper_set_fpsw Richard Henderson
2021-05-28 15:34 ` Yoshinori Sato
2021-05-27 4:14 ` [PATCH 07/11] target/rx: Use FloatRoundMode " Richard Henderson
2021-05-28 15:35 ` Yoshinori Sato
2021-06-01 3:27 ` Philippe Mathieu-Daudé
2021-05-27 4:14 ` [PATCH 08/11] target/rx: Fix setting of FPSW.CE Richard Henderson
2021-05-28 15:35 ` Yoshinori Sato
2021-05-27 4:14 ` [PATCH 09/11] target/mips: Drop inline markers from msa_helper.c Richard Henderson
2021-06-01 3:27 ` Philippe Mathieu-Daudé
2021-05-27 4:14 ` [PATCH 10/11] target/mips: Do not check MSACSR_FS_MASK in update_msacsr Richard Henderson
2021-06-19 15:15 ` Philippe Mathieu-Daudé
2021-05-27 4:14 ` [PATCH 11/11] target/mips: Drop denormal operand to update_msacsr Richard Henderson
2021-06-01 3:29 ` Philippe Mathieu-Daudé
2021-06-07 16:31 ` [PATCH 00/11] softfloat: Improve denormal handling Alex Bennée
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=44a76e8c6504461cbd4dc5752f0d443b@tachyum.com \
--to=mmorrell@tachyum.com \
--cc=alex.bennee@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).