On Sun, 17 May 2026 at 01:31, Richard Henderson
<[email protected]> wrote:
>
> Signed-off-by: Richard Henderson <[email protected]>
> +/*
> + * Use float_minmax_ismag to get the absolute value min/max.
> + * Avoid float_minmax_is{num,number} so that we get normal NaN processing.
> + * If the result is not a nan, take the absolute value.
> + */
> +#define DO_FAMINMAX(NAME, TYPE, MIN) \
> +TYPE TYPE##_##NAME(TYPE a, TYPE b, float_status *s) \
> +{ \
> + float_status local = *s; \
> + set_flush_to_zero(0, &local); \
> + set_flush_inputs_to_zero(0, &local); \
> + TYPE r = TYPE##_minmax(a, b, &local, MIN | float_minmax_ismag); \
> + if (!TYPE##_is_any_nan(r)) { \
> + r = TYPE##_abs(r); \
> + } \
> + float_raise(get_float_exception_flags(&local) \
> + & ~float_flag_input_denormal_used, s); \
> + return r; \
> +}
Because we use either FPST_A64 or FPST_A64_F16 here, this doesn't
handle the FPCR.AH = 1 case right. The pseudocode FPAbsMax squashes
AH to 0, so it always has the behaviour of the "normal Arm" operations
for things like what the default NaN value is and which NaN to
propagate when both arguments are NaNs. FPST_A64 and FPST_A64_F16
for QEMU both change behaviour when FPCR.AH is set.
I can't see an existing fp_status word that we have that has the
desired "ignore AH even when AH is set" handling; a simple fix is:
diff --git a/target/arm/tcg/vec_helper64.c b/target/arm/tcg/vec_helper64.c
index 2f481ac489..fc2566bddd 100644
--- a/target/arm/tcg/vec_helper64.c
+++ b/target/arm/tcg/vec_helper64.c
@@ -8,6 +8,7 @@
#include "qemu/osdep.h"
#include "cpu.h"
+#include "internals.h"
#include "helper.h"
#include "helper-a64.h"
#include "helper-sme.h"
@@ -152,6 +153,7 @@ TYPE TYPE##_##NAME(TYPE a, TYPE b, float_status
*s) \
float_status local = *s; \
set_flush_to_zero(0, &local); \
set_flush_inputs_to_zero(0, &local); \
+ arm_set_default_fp_behaviours(&local); \
TYPE r = TYPE##_minmax(a, b, &local, MIN | float_minmax_ismag); \
if (!TYPE##_is_any_nan(r)) { \
r = TYPE##_abs(r); \
thanks
-- PMM