On 5/16/26 11:18, Richard Henderson wrote:
On 5/14/26 03:35, Peter Maydell wrote:
On Tue, 21 Apr 2026 at 06:15, Richard Henderson
<[email protected]> wrote:
Signed-off-by: Richard Henderson <[email protected]>
---
target/arm/cpu-features.h | 5 +++++
target/arm/tcg/helper-a64-defs.h | 7 +++++++
target/arm/tcg/vec_internal.h | 7 +++++++
target/arm/tcg/translate-a64.c | 14 +++++++++++++
target/arm/tcg/vec_helper64.c | 35 ++++++++++++++++++++++++++++++++
target/arm/tcg/a64.decode | 5 +++++
6 files changed, 73 insertions(+)
+#define DO_FAMINMAX(NAME, TYPE, FN) \
+TYPE TYPE##_##NAME(TYPE a, TYPE b, float_status *s) \
+{ \
+ bool save_fz = get_flush_to_zero(s); \
+ bool save_fiz = get_flush_inputs_to_zero(s); \
+ int new_flags, save_flags = get_float_exception_flags(s); \
+ \
+ set_flush_to_zero(0, s); \
+ set_flush_inputs_to_zero(0, s); \
+ TYPE r = TYPE##_##FN(TYPE##_abs(a), TYPE##_abs(b), s); \
+ \
+ set_flush_to_zero(save_fz, s); \
+ set_flush_inputs_to_zero(save_fiz, s); \
+ new_flags = get_float_exception_flags(s); \
+ new_flags = (save_flags & float_flag_input_denormal_used) \
+ | (new_flags & ~float_flag_input_denormal_used); \
+ set_float_exception_flags(new_flags, s); \
+ \
+ return r; \
+}
I don't think this has the right behaviour for NaN inputs.
We don't special-case NaNs in this function, and we pass
our inputs to the floatN_abs() functions, which also don't
special-case NaNs, they just flip the sign bit. So if the
input is a NaN with the sign bit set, the max/min function
will propagate a sign-flipped NaN to the output, rather
than correctly propagating the input NaN untouched.
Yep.
See FPAbsMax{N}, where the sign bits are squashed before unpacking:
let op1 = '0'::op1_in[N-2:0];
let op2 = '0'::op2_in[N-2:0];
let (type1,-,value1) = FPUnpack{N}(op1, fpcr);
let (type2,-,value2) = FPUnpack{N}(op2, fpcr);
Ho hum. And then FPProcessNaNs uses op[12]_in. So, yeah, the absolute value isn't used
if there's a NaN.
r~