[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 35/36] target/arm: Use FPST_A64_F16 for halfprec-to-other conversi
From: |
Peter Maydell |
Subject: |
[PULL 35/36] target/arm: Use FPST_A64_F16 for halfprec-to-other conversions |
Date: |
Tue, 28 Jan 2025 20:13:13 +0000 |
We should be using the F16-specific float_status for conversions from
half-precision, because halfprec inputs never set Input Denormal.
Without FEAT_AHP, using the wrong fpst here had no effect, because
the only difference between the A64_F16 and A64 fpst is its handling
of flush-to-zero on input and output, and the helper functions
vfp_fcvt_f16_to_* and vfp_fcvt_*_to_f16 all explicitly squash the
relevant flushing flags, and flush_inputs_to_zero was the only way
that IDC could be set.
With FEAT_AHP, the FPCR.AH=1 behaviour sets IDC for
input_denormal_used, which we will only ignore in
vfp_get_fpsr_from_host() for the A64_F16 fpst; so it matters that we
use that one for f16 inputs (and the normal one for single/double to
f16 conversions).
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20250124162836.2332150-27-peter.maydell@linaro.org
---
target/arm/tcg/translate-a64.c | 9 ++++++---
target/arm/tcg/translate-sve.c | 4 ++--
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c
index 703f265f20e..0b76a2cdb78 100644
--- a/target/arm/tcg/translate-a64.c
+++ b/target/arm/tcg/translate-a64.c
@@ -8568,7 +8568,7 @@ static bool trans_FCVT_s_sh(DisasContext *s, arg_rr *a)
if (fp_access_check(s)) {
TCGv_i32 tcg_rn = read_fp_hreg(s, a->rn);
TCGv_i32 tcg_rd = tcg_temp_new_i32();
- TCGv_ptr tcg_fpst = fpstatus_ptr(FPST_A64);
+ TCGv_ptr tcg_fpst = fpstatus_ptr(FPST_A64_F16);
TCGv_i32 tcg_ahp = get_ahp_flag();
gen_helper_vfp_fcvt_f16_to_f32(tcg_rd, tcg_rn, tcg_fpst, tcg_ahp);
@@ -8582,7 +8582,7 @@ static bool trans_FCVT_s_dh(DisasContext *s, arg_rr *a)
if (fp_access_check(s)) {
TCGv_i32 tcg_rn = read_fp_hreg(s, a->rn);
TCGv_i64 tcg_rd = tcg_temp_new_i64();
- TCGv_ptr tcg_fpst = fpstatus_ptr(FPST_A64);
+ TCGv_ptr tcg_fpst = fpstatus_ptr(FPST_A64_F16);
TCGv_i32 tcg_ahp = get_ahp_flag();
gen_helper_vfp_fcvt_f16_to_f64(tcg_rd, tcg_rn, tcg_fpst, tcg_ahp);
@@ -9511,13 +9511,14 @@ static bool trans_FCVTL_v(DisasContext *s, arg_qrr_e *a)
return true;
}
- fpst = fpstatus_ptr(FPST_A64);
if (a->esz == MO_64) {
/* 32 -> 64 bit fp conversion */
TCGv_i64 tcg_res[2];
TCGv_i32 tcg_op = tcg_temp_new_i32();
int srcelt = a->q ? 2 : 0;
+ fpst = fpstatus_ptr(FPST_A64);
+
for (pass = 0; pass < 2; pass++) {
tcg_res[pass] = tcg_temp_new_i64();
read_vec_element_i32(s, tcg_op, a->rn, srcelt + pass, MO_32);
@@ -9532,6 +9533,8 @@ static bool trans_FCVTL_v(DisasContext *s, arg_qrr_e *a)
TCGv_i32 tcg_res[4];
TCGv_i32 ahp = get_ahp_flag();
+ fpst = fpstatus_ptr(FPST_A64_F16);
+
for (pass = 0; pass < 4; pass++) {
tcg_res[pass] = tcg_temp_new_i32();
read_vec_element_i32(s, tcg_res[pass], a->rn, srcelt + pass,
MO_16);
diff --git a/target/arm/tcg/translate-sve.c b/target/arm/tcg/translate-sve.c
index a7dbea5acd0..e1788330aa7 100644
--- a/target/arm/tcg/translate-sve.c
+++ b/target/arm/tcg/translate-sve.c
@@ -3887,7 +3887,7 @@ TRANS_FEAT(FCMLA_zzxz, aa64_sve, gen_gvec_fpst_zzzz,
fcmla_idx_fns[a->esz],
TRANS_FEAT(FCVT_sh, aa64_sve, gen_gvec_fpst_arg_zpz,
gen_helper_sve_fcvt_sh, a, 0, FPST_A64)
TRANS_FEAT(FCVT_hs, aa64_sve, gen_gvec_fpst_arg_zpz,
- gen_helper_sve_fcvt_hs, a, 0, FPST_A64)
+ gen_helper_sve_fcvt_hs, a, 0, FPST_A64_F16)
TRANS_FEAT(BFCVT, aa64_sve_bf16, gen_gvec_fpst_arg_zpz,
gen_helper_sve_bfcvt, a, 0, FPST_A64)
@@ -3895,7 +3895,7 @@ TRANS_FEAT(BFCVT, aa64_sve_bf16, gen_gvec_fpst_arg_zpz,
TRANS_FEAT(FCVT_dh, aa64_sve, gen_gvec_fpst_arg_zpz,
gen_helper_sve_fcvt_dh, a, 0, FPST_A64)
TRANS_FEAT(FCVT_hd, aa64_sve, gen_gvec_fpst_arg_zpz,
- gen_helper_sve_fcvt_hd, a, 0, FPST_A64)
+ gen_helper_sve_fcvt_hd, a, 0, FPST_A64_F16)
TRANS_FEAT(FCVT_ds, aa64_sve, gen_gvec_fpst_arg_zpz,
gen_helper_sve_fcvt_ds, a, 0, FPST_A64)
TRANS_FEAT(FCVT_sd, aa64_sve, gen_gvec_fpst_arg_zpz,
--
2.34.1
- [PULL 16/36] target/arm: Use uint32_t in vfp_exceptbits_from_host(), (continued)
- [PULL 16/36] target/arm: Use uint32_t in vfp_exceptbits_from_host(), Peter Maydell, 2025/01/28
- [PULL 17/36] target/arm: Define new fp_status_a32 and fp_status_a64, Peter Maydell, 2025/01/28
- [PULL 19/36] target/arm: Use fp_status_a64 or fp_status_a32 in is_ebf(), Peter Maydell, 2025/01/28
- [PULL 18/36] target/arm: Use vfp.fp_status_a64 in A64-only helper functions, Peter Maydell, 2025/01/28
- [PULL 22/36] target/arm: Use FPST_A32 in A32 decoder, Peter Maydell, 2025/01/28
- [PULL 20/36] target/arm: Use fp_status_a32 in vjvct helper, Peter Maydell, 2025/01/28
- [PULL 21/36] target/arm: Use fp_status_a32 in vfp_cmp helpers, Peter Maydell, 2025/01/28
- [PULL 26/36] target/arm: Use fp_status_f16_a32 in AArch32-only helpers, Peter Maydell, 2025/01/28
- [PULL 23/36] target/arm: Use FPST_A64 in A64 decoder, Peter Maydell, 2025/01/28
- [PULL 28/36] target/arm: Use FPST_A32_F16 in A32 decoder, Peter Maydell, 2025/01/28
- [PULL 35/36] target/arm: Use FPST_A64_F16 for halfprec-to-other conversions,
Peter Maydell <=
- [PULL 34/36] target/arm: Remove redundant advsimd float16 helpers, Peter Maydell, 2025/01/28
- [PULL 36/36] hw/usb/canokey: Fix buffer overflow for OUT packet, Peter Maydell, 2025/01/28
- [PULL 25/36] target/arm: Define new fp_status_f16_a32 and fp_status_f16_a64, Peter Maydell, 2025/01/28
- [PULL 24/36] target/arm: Remove now-unused vfp.fp_status and FPST_FPCR, Peter Maydell, 2025/01/28
- [PULL 27/36] target/arm: Use fp_status_f16_a64 in AArch64-only helpers, Peter Maydell, 2025/01/28
- [PULL 31/36] fpu: Rename float_flag_input_denormal to float_flag_input_denormal_flushed, Peter Maydell, 2025/01/28
- [PULL 30/36] target/arm: Remove now-unused vfp.fp_status_f16 and FPST_FPCR_F16, Peter Maydell, 2025/01/28
- [PULL 32/36] fpu: Rename float_flag_output_denormal to float_flag_output_denormal_flushed, Peter Maydell, 2025/01/28
- [PULL 33/36] fpu: Fix a comment in softfloat-types.h, Peter Maydell, 2025/01/28
- [PULL 29/36] target/arm: Use FPST_A64_F16 in A64 decoder, Peter Maydell, 2025/01/28