target/arm: tcg vector cleanups
v2 cover target/arm: tcg vector cleanups
Generic tcg now has support for folding of OR,
and has grown min/max primitives.
r~
Richard Henderson (5):
target/arm: Rely on optimization within tcg_gen_gvec_or target/arm: Use vector minmax expanders for aarch64 target/arm: Use vector minmax expanders for aarch32 target/arm: Use tcg integer min/max primitives for neon target/arm: Remove neon min/max helpers
target/arm/helper.h | 12 ---------- target/arm/neon_helper.c | 12 ---------- target/arm/translate-a64.c | 41 +++++++++++++--------------------- target/arm/translate-sve.c | 6 +---- target/arm/translate.c | 45 ++++++++++++++++++++++---------------- 5 files changed, 42 insertions(+), 74 deletions(-)
Signature · 1 line
2.17.2
PATCH v2 1/5 target/arm: Rely on optimization within tcg_gen_gvec_or
Since we're now handling a == b generically, we no longer need to do it by hand within target/arm/.
--- target/arm/translate-a64.c | 6 +----- target/arm/translate-sve.c | 6 +----- target/arm/translate.c | 12 +++--------- 3 files changed, 5 insertions(+), 19 deletions(-)
target/arm/translate-a64.c +1 -5
@@ -10648,11 +10648,7 @@ static void disas_simd_3same_logic(DisasContext *s, uint32_t insn)gen_gvec_fn3 (s, is_q, rd, rn, rm, tcg_gen_gvec_andc,0 );return ;case 2 :/* ORR */ -if (rn == rm) {/* MOV */ -gen_gvec_fn2 (s, is_q, rd, rn, tcg_gen_gvec_mov,0 ); - }else { -gen_gvec_fn3 (s, is_q, rd, rn, rm, tcg_gen_gvec_or,0 ); - } +gen_gvec_fn3 (s, is_q, rd, rn, rm, tcg_gen_gvec_or,0 );return ;case 3 :/* ORN */ gen_gvec_fn3 (s, is_q, rd, rn, rm, tcg_gen_gvec_orc,0 );
target/arm/translate-sve.c +1 -5
@@ -280,11 +280,7 @@ static bool trans_AND_zzz(DisasContext *s, arg_rrr_esz *a)static bool trans_ORR_zzz (DisasContext *s,arg_rrr_esz *a) { -if (a->rn == a->rm) {/* MOV */ -return do_mov_z (s, a->rd, a->rn); - }else { -return do_vector3_z (s, tcg_gen_gvec_or,0 , a->rd, a->rn, a->rm); - } +return do_vector3_z (s, tcg_gen_gvec_or,0 , a->rd, a->rn, a->rm); }static bool trans_EOR_zzz (DisasContext *s,arg_rrr_esz *a)
target/arm/translate.c +3 -9
@@ -6294,15 +6294,9 @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn)tcg_gen_gvec_andc (0 , rd_ofs, rn_ofs, rm_ofs, vec_size, vec_size);break ; -case 2 : -if (rn == rm) { -/* VMOV */ -tcg_gen_gvec_mov (0 , rd_ofs, rn_ofs, vec_size, vec_size); - }else { -/* VORR */ -tcg_gen_gvec_or (0 , rd_ofs, rn_ofs, rm_ofs, - vec_size, vec_size); - } +case 2 :/* VORR */ +tcg_gen_gvec_or (0 , rd_ofs, rn_ofs, rm_ofs, + vec_size, vec_size);break ;case 3 :/* VORN */ tcg_gen_gvec_orc(0, rd_ofs, rn_ofs, rm_ofs,
Signature · 1 line
2.17.2
PATCH v2 2/5 target/arm: Use vector minmax expanders for aarch64
In reply to Richard Henderson--- target/arm/translate-a64.c | 35 ++++++++++++++--------------------- 1 file changed, 14 insertions(+), 21 deletions(-)
target/arm/translate-a64.c +14 -21
@@ -10948,6 +10948,20 @@ static void disas_simd_3same_int(DisasContext *s, uint32_t insn) }switch (opcode) { +case 0x0c :/* SMAX, UMAX */ +if (u) { +gen_gvec_fn3 (s, is_q, rd, rn, rm, tcg_gen_gvec_umax, size); + }else { +gen_gvec_fn3 (s, is_q, rd, rn, rm, tcg_gen_gvec_smax, size); + } +return ; +case 0x0d :/* SMIN, UMIN */ +if (u) { +gen_gvec_fn3 (s, is_q, rd, rn, rm, tcg_gen_gvec_umin, size); + }else { +gen_gvec_fn3 (s, is_q, rd, rn, rm, tcg_gen_gvec_smin, size); + } +return ;case 0x10 :/* ADD, SUB */ if (u) {gen_gvec_fn3 (s, is_q, rd, rn, rm, tcg_gen_gvec_sub, size);
@@ -11109,27 +11123,6 @@ static void disas_simd_3same_int(DisasContext *s, uint32_t insn) genenvfn = fns[size][u];break ; } -case 0xc :/* SMAX, UMAX */ - { -static NeonGenTwoOpFn *const fns[3 ][2 ] = { - { gen_helper_neon_max_s8, gen_helper_neon_max_u8 }, - { gen_helper_neon_max_s16, gen_helper_neon_max_u16 }, - { tcg_gen_smax_i32, tcg_gen_umax_i32 }, - }; - genfn = fns[size][u]; -break ; - } - -case 0xd :/* SMIN, UMIN */ - { -static NeonGenTwoOpFn *const fns[3 ][2 ] = { - { gen_helper_neon_min_s8, gen_helper_neon_min_u8 }, - { gen_helper_neon_min_s16, gen_helper_neon_min_u16 }, - { tcg_gen_smin_i32, tcg_gen_umin_i32 }, - }; - genfn = fns[size][u]; -break ; - }case 0xe :/* SABD, UABD */ case 0xf :/* SABA, UABA */ {
Signature · 1 line
2.17.2
PATCH v2 3/5 target/arm: Use vector minmax expanders for aarch32
In reply to Richard Henderson--- target/arm/translate.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-)
target/arm/translate.c +19 -6
@@ -6368,6 +6368,25 @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn)tcg_gen_gvec_cmp (u ?TCG_COND_GEU :TCG_COND_GE , size, rd_ofs, rn_ofs, rm_ofs, vec_size, vec_size);return 0 ; + +case NEON_3R_VMAX : +if (u) { +tcg_gen_gvec_umax (size, rd_ofs, rn_ofs, rm_ofs, + vec_size, vec_size); + }else { +tcg_gen_gvec_smax (size, rd_ofs, rn_ofs, rm_ofs, + vec_size, vec_size); + } +return 0 ; +case NEON_3R_VMIN : +if (u) { +tcg_gen_gvec_umin (size, rd_ofs, rn_ofs, rm_ofs, + vec_size, vec_size); + }else { +tcg_gen_gvec_smin (size, rd_ofs, rn_ofs, rm_ofs, + vec_size, vec_size); + } +return 0 ; }if (size ==3 ) {
@@ -6533,12 +6552,6 @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn)case NEON_3R_VQRSHL :GEN_NEON_INTEGER_OP_ENV (qrshl);break ; -case NEON_3R_VMAX : -GEN_NEON_INTEGER_OP (max); -break ; -case NEON_3R_VMIN : -GEN_NEON_INTEGER_OP (min); -break ;case NEON_3R_VABD :GEN_NEON_INTEGER_OP (abd);break ;
Signature · 1 line
2.17.2
PATCH v2 4/5 target/arm: Use tcg integer min/max primitives for neon
In reply to Richard HendersonThe 32-bit PMIN/PMAX has been decomposed to scalars, and so can be trivially expanded inline.
--- target/arm/translate.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
target/arm/translate.c +4 -4
@@ -4760,10 +4760,10 @@ static inline void gen_neon_rsb(int size, TCGv_i32 t0, TCGv_i32 t1) }/* 32-bit pairwise ops end up the same as the elementwise versions. */ -#define gen_helper_neon_pmax_s32 gen_helper_neon_max_s32 -#define gen_helper_neon_pmax_u32 gen_helper_neon_max_u32 -#define gen_helper_neon_pmin_s32 gen_helper_neon_min_s32 -#define gen_helper_neon_pmin_u32 gen_helper_neon_min_u32 +#define gen_helper_neon_pmax_s32 tcg_gen_smax_i32 +#define gen_helper_neon_pmax_u32 tcg_gen_umax_i32 +#define gen_helper_neon_pmin_s32 tcg_gen_smin_i32 +#define gen_helper_neon_pmin_u32 tcg_gen_umin_i32#define GEN_NEON_INTEGER_OP_ENV (name) do { \ switch ((size << 1) | u) { \
Signature · 1 line
2.17.2
PATCH v2 5/5 target/arm: Remove neon min/max helpers
In reply to Richard HendersonThese are now unused.
--- target/arm/helper.h | 12 ------------ target/arm/neon_helper.c | 12 ------------ 2 files changed, 24 deletions(-)
target/arm/helper.h +0 -12
@@ -276,18 +276,6 @@ DEF_HELPER_2(neon_cge_s16, i32, i32, i32) DEF_HELPER_2(neon_cge_u32, i32, i32, i32) DEF_HELPER_2(neon_cge_s32, i32, i32, i32) -DEF_HELPER_2(neon_min_u8, i32, i32, i32) -DEF_HELPER_2(neon_min_s8, i32, i32, i32) -DEF_HELPER_2(neon_min_u16, i32, i32, i32) -DEF_HELPER_2(neon_min_s16, i32, i32, i32) -DEF_HELPER_2(neon_min_u32, i32, i32, i32) -DEF_HELPER_2(neon_min_s32, i32, i32, i32) -DEF_HELPER_2(neon_max_u8, i32, i32, i32) -DEF_HELPER_2(neon_max_s8, i32, i32, i32) -DEF_HELPER_2(neon_max_u16, i32, i32, i32) -DEF_HELPER_2(neon_max_s16, i32, i32, i32) -DEF_HELPER_2(neon_max_u32, i32, i32, i32) -DEF_HELPER_2(neon_max_s32, i32, i32, i32) DEF_HELPER_2(neon_pmin_u8, i32, i32, i32) DEF_HELPER_2(neon_pmin_s8, i32, i32, i32)DEF_HELPER_2 (neon_pmin_u16, i32, i32, i32)
target/arm/neon_helper.c +0 -12
@@ -581,12 +581,6 @@ NEON_VOP(cge_u32, neon_u32, 1)#undef NEON_FN#define NEON_FN (dest, src1, src2) dest = (src1 < src2) ? src1 : src2 -NEON_VOP(min_s8, neon_s8, 4) -NEON_VOP(min_u8, neon_u8, 4) -NEON_VOP(min_s16, neon_s16, 2) -NEON_VOP(min_u16, neon_u16, 2) -NEON_VOP(min_s32, neon_s32, 1) -NEON_VOP(min_u32, neon_u32, 1) NEON_POP(pmin_s8, neon_s8, 4) NEON_POP(pmin_u8, neon_u8, 4)NEON_POP (pmin_s16, neon_s16,2 )
@@ -594,12 +588,6 @@ NEON_POP(pmin_u16, neon_u16, 2)#undef NEON_FN#define NEON_FN (dest, src1, src2) dest = (src1 > src2) ? src1 : src2 -NEON_VOP(max_s8, neon_s8, 4) -NEON_VOP(max_u8, neon_u8, 4) -NEON_VOP(max_s16, neon_s16, 2) -NEON_VOP(max_u16, neon_u16, 2) -NEON_VOP(max_s32, neon_s32, 1) -NEON_VOP(max_u32, neon_u32, 1) NEON_POP(pmax_s8, neon_s8, 4) NEON_POP(pmax_u8, neon_u8, 4)NEON_POP (pmax_s16, neon_s16,2 )
Signature · 1 line
2.17.2