Message ID | 20210527041405.391567-5-richard.henderson@linaro.org |
---|---|
State | New |
Headers | show |
Series | softfloat: Improve denormal handling | expand |
Richard Henderson <richard.henderson@linaro.org> writes: > Create a new exception flag for reporting output denormals > that are not flushed to zero. > > Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Alex Bennée <alex.bennee@linaro.org> -- Alex Bennée
On 5/27/21 6:13 AM, Richard Henderson wrote: > Create a new exception flag for reporting output denormals > that are not flushed to zero. > > Signed-off-by: Richard Henderson <richard.henderson@linaro.org> > --- > include/fpu/softfloat-types.h | 3 ++- > fpu/softfloat-parts.c.inc | 8 ++++++-- > 2 files changed, 8 insertions(+), 3 deletions(-) Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
diff --git a/include/fpu/softfloat-types.h b/include/fpu/softfloat-types.h index 174100e50e..83632aa09f 100644 --- a/include/fpu/softfloat-types.h +++ b/include/fpu/softfloat-types.h @@ -151,6 +151,7 @@ enum { 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 */ + float_flag_result_denormal = 0x0100, /* denormal result, not flushed */ }; /* @@ -170,8 +171,8 @@ typedef enum __attribute__((__packed__)) { */ typedef struct float_status { + uint16_t float_exception_flags; FloatRoundMode float_rounding_mode; - uint8_t float_exception_flags; FloatX80RoundPrec floatx80_rounding_precision; bool tininess_before_rounding; /* should denormalised results go to zero and set the inexact flag? */ diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc index 16d4425419..a21fcec3e5 100644 --- a/fpu/softfloat-parts.c.inc +++ b/fpu/softfloat-parts.c.inc @@ -276,8 +276,12 @@ static void partsN(uncanon_normal)(FloatPartsN *p, float_status *s, if (is_tiny && (flags & float_flag_inexact)) { flags |= float_flag_underflow; } - if (exp == 0 && frac_eqz(p)) { - p->cls = float_class_zero; + if (exp == 0) { + if (frac_eqz(p)) { + p->cls = float_class_zero; + } else { + flags |= float_flag_result_denormal; + } } } p->exp = exp;
Create a new exception flag for reporting output denormals that are not flushed to zero. Signed-off-by: Richard Henderson <richard.henderson@linaro.org> --- include/fpu/softfloat-types.h | 3 ++- fpu/softfloat-parts.c.inc | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) -- 2.25.1