[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [PATCH 03/11] softfloat: Introduce float_flag_inorm_denormal
From: |
Michael Morrell |
Subject: |
RE: [PATCH 03/11] softfloat: Introduce float_flag_inorm_denormal |
Date: |
Fri, 28 May 2021 17:41:12 +0000 |
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
- [PATCH 00/11] softfloat: Improve denormal handling, Richard Henderson, 2021/05/27
- [PATCH 03/11] softfloat: Introduce float_flag_inorm_denormal, Richard Henderson, 2021/05/27
- RE: [PATCH 03/11] softfloat: Introduce float_flag_inorm_denormal,
Michael Morrell <=
- [PATCH 01/11] softfloat: Rename float_flag_input_denormal to float_flag_iflush_denormal, Richard Henderson, 2021/05/27
- [PATCH 07/11] target/rx: Use FloatRoundMode in helper_set_fpsw, Richard Henderson, 2021/05/27
- [PATCH 02/11] softfloat: Rename float_flag_output_denormal to float_flag_oflush_denormal, Richard Henderson, 2021/05/27
- [PATCH 06/11] target/rx: Handle the FPSW.DN bit in helper_set_fpsw, Richard Henderson, 2021/05/27
- [PATCH 08/11] target/rx: Fix setting of FPSW.CE, Richard Henderson, 2021/05/27