diff options
author | Andre Vieira <andre.simoesdiasvieira@arm.com> | 2023-02-02 10:01:30 +0000 |
---|---|---|
committer | Andre Vieira <andre.simoesdiasvieira@arm.com> | 2023-02-02 10:01:30 +0000 |
commit | e0bc13d396002f88b8c27e3a23c7eaee54d379d5 (patch) | |
tree | b92d40d0cecfc2f946a7e333b3601d37f421cd49 /gcc/config/arm/arm-builtins.cc | |
parent | d45ec8a732f449647afa89e46b80a4e0614ec28d (diff) | |
download | gcc-e0bc13d396002f88b8c27e3a23c7eaee54d379d5.zip gcc-e0bc13d396002f88b8c27e3a23c7eaee54d379d5.tar.gz gcc-e0bc13d396002f88b8c27e3a23c7eaee54d379d5.tar.bz2 |
arm: Fix MVE predicates synthesis [PR 108443]
This patch fixes the way we synthesize MVE predicate immediates and fixes some
other inconsistencies around predicates. For instance this patch fixes the modes
used in the vctp intrinsics, to couple them with predicate modes with the
appropriate lane numbers. For this V2QI is added to represent a predicate
created by vctp64q. The reason we use V2QI and not for instance a V2BI with
8-bit boolean modes is because we are trying to avoid having two 'INT' modes of
the same size. We make sure we use the V2QI mode instead of HI for any
instruction working on two lanes of 64-bits consuming a predicate.
gcc/ChangeLog:
PR target/108443
* config/arm/arm.h (VALID_MVE_PRED_MODE): Add V2QI.
* config/arm/arm.cc (thumb2_legitimate_address_p): Use HImode for
addressing MVE predicate modes.
(mve_bool_vec_to_const): Change to represent correct MVE predicate
format.
(arm_hard_regno_mode_ok): Use VALID_MVE_PRED_MODE instead of checking
modes.
(arm_vector_mode_supported_p): Likewise.
(arm_mode_to_pred_mode): Add V2QI.
* config/arm/arm-builtins.cc (UNOP_PRED_UNONE_QUALIFIERS): New
qualifier.
(UNOP_PRED_PRED_QUALIFIERS): New qualifier
(BINOP_PRED_UNONE_PRED_QUALIFIERS): New qualifier.
(v2qi_UP): New macro.
(v4bi_UP): New macro.
(v8bi_UP): New macro.
(v16bi_UP): New macro.
(arm_expand_builtin_args): Make it able to expand the new predicate
modes.
* config/arm/arm-modes.def (V2QI): New mode.
* config/arm/arm-simd-builtin-types.def (Pred1x16_t, Pred2x8_t
Pred4x4_t): Remove unused predicate builtin types.
* config/arm/arm_mve.h (__arm_vctp16q, __arm_vctp32q, __arm_vctp64q,
__arm_vctp8q, __arm_vpnot, __arm_vctp8q_m, __arm_vctp64q_m,
__arm_vctp32q_m, __arm_vctp16q_m): Use predicate modes.
* config/arm/arm_mve_builtins.def (vctp16q, vctp32q, vctp64q, vctp8q,
vpnot, vctp8q_m, vctp16q_m, vctp32q_m, vctp64q_m): Likewise.
* config/arm/constraints.md (DB): Check for VALID_MVE_PRED_MODE instead
of MODE_VECTOR_BOOL.
* config/arm/iterators.md (MVE_7, MVE_7_HI): Add V2QI
(MVE_VPRED): Likewise.
(MVE_vpred): Add V2QI and map upper case predicate modes to lower case.
(MVE_vctp): New mode attribute.
(mode1): Remove.
(VCTPQ): Remove.
(VCTPQ_M): Remove.
* config/arm/mve.md (mve_vctp<mode1>qhi): Rename this...
(mve_vctp<MVE_vctp>q<MVE_vpred>): ... to this. And use new mode
attributes.
(mve_vpnothi): Rename this...
(mve_vpnotv16bi): ... to this.
(mve_vctp<mode1>q_mhi): Rename this...
(mve_vctp<MVE_vctp>q_m<MVE_vpred>):... to this.
(mve_vldrdq_gather_base_z_<supf>v2di,
mve_vldrdq_gather_offset_z_<supf>v2di,
mve_vldrdq_gather_shifted_offset_z_<supf>v2di,
mve_vstrdq_scatter_base_p_<supf>v2di,
mve_vstrdq_scatter_offset_p_<supf>v2di,
mve_vstrdq_scatter_offset_p_<supf>v2di_insn,
mve_vstrdq_scatter_shifted_offset_p_<supf>v2di,
mve_vstrdq_scatter_shifted_offset_p_<supf>v2di_insn,
mve_vstrdq_scatter_base_wb_p_<supf>v2di,
mve_vldrdq_gather_base_wb_z_<supf>v2di,
mve_vldrdq_gather_base_nowb_z_<supf>v2di,
mve_vldrdq_gather_base_wb_z_<supf>v2di_insn): Use V2QI insead of HI for
predicates.
* config/arm/unspecs.md (VCTP8Q, VCTP16Q, VCTP32Q, VCTP64Q): Replace
these...
(VCTP): ... with this.
(VCTP8Q_M, VCTP16Q_M, VCTP32Q_M, VCTP64Q_M): Replace these...
(VCTP_M): ... with this.
* config/arm/vfp.md (*thumb2_movhi_vfp, *thumb2_movhi_fp16): Use
VALID_MVE_PRED_MODE instead of checking for MODE_VECTOR_BOOL class.
gcc/testsuite/ChangeLog:
* gcc.target/arm/mve/pr108443-run.c: New test.
* gcc.target/arm/mve/pr108443.c: New test.
Diffstat (limited to 'gcc/config/arm/arm-builtins.cc')
-rw-r--r-- | gcc/config/arm/arm-builtins.cc | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/gcc/config/arm/arm-builtins.cc b/gcc/config/arm/arm-builtins.cc index 58bf856..9f5c568 100644 --- a/gcc/config/arm/arm-builtins.cc +++ b/gcc/config/arm/arm-builtins.cc @@ -385,6 +385,19 @@ arm_unop_unone_imm_qualifiers[SIMD_MAX_BUILTIN_ARGS] (arm_unop_unone_imm_qualifiers) static enum arm_type_qualifiers +arm_unop_pred_unone_qualifiers[SIMD_MAX_BUILTIN_ARGS] + = { qualifier_predicate, qualifier_unsigned }; +#define UNOP_PRED_UNONE_QUALIFIERS \ + (arm_unop_pred_unone_qualifiers) + +static enum arm_type_qualifiers +arm_unop_pred_pred_qualifiers[SIMD_MAX_BUILTIN_ARGS] + = { qualifier_predicate, qualifier_predicate }; +#define UNOP_PRED_PRED_QUALIFIERS \ + (arm_unop_pred_pred_qualifiers) + + +static enum arm_type_qualifiers arm_binop_none_none_none_qualifiers[SIMD_MAX_BUILTIN_ARGS] = { qualifier_none, qualifier_none, qualifier_none }; #define BINOP_NONE_NONE_NONE_QUALIFIERS \ @@ -427,6 +440,12 @@ arm_binop_pred_unone_unone_qualifiers[SIMD_MAX_BUILTIN_ARGS] (arm_binop_pred_unone_unone_qualifiers) static enum arm_type_qualifiers +arm_binop_pred_unone_pred_qualifiers[SIMD_MAX_BUILTIN_ARGS] + = { qualifier_predicate, qualifier_unsigned, qualifier_predicate }; +#define BINOP_PRED_UNONE_PRED_QUALIFIERS \ + (arm_binop_pred_unone_pred_qualifiers) + +static enum arm_type_qualifiers arm_binop_unone_none_imm_qualifiers[SIMD_MAX_BUILTIN_ARGS] = { qualifier_unsigned, qualifier_none, qualifier_immediate }; #define BINOP_UNONE_NONE_IMM_QUALIFIERS \ @@ -851,6 +870,10 @@ arm_set_sat_qualifiers[SIMD_MAX_BUILTIN_ARGS] = { qualifier_void, qualifier_none }; #define SET_SAT_QUALIFIERS (arm_set_sat_qualifiers) +#define v2qi_UP E_V2QImode +#define v4bi_UP E_V4BImode +#define v8bi_UP E_V8BImode +#define v16bi_UP E_V16BImode #define v8qi_UP E_V8QImode #define v4hi_UP E_V4HImode #define v4hf_UP E_V4HFmode @@ -2989,11 +3012,14 @@ arm_expand_builtin_args (rtx target, machine_mode map_mode, int fcode, op[argc] = convert_memory_address (Pmode, op[argc]); /* MVE uses mve_pred16_t (aka HImode) for vectors of - predicates. */ - if (GET_MODE_CLASS (mode[argc]) == MODE_VECTOR_BOOL) + predicates, but internally we use V16BI/V8BI/V4BI/V2QI for + MVE predicate modes. */ + if (TARGET_HAVE_MVE && VALID_MVE_PRED_MODE (mode[argc])) op[argc] = gen_lowpart (mode[argc], op[argc]); - /*gcc_assert (GET_MODE (op[argc]) == mode[argc]); */ + gcc_assert (GET_MODE (op[argc]) == mode[argc] + || (GET_MODE(op[argc]) == E_VOIDmode + && CONSTANT_P (op[argc]))); if (!(*insn_data[icode].operand[opno].predicate) (op[argc], mode[argc])) op[argc] = copy_to_mode_reg (mode[argc], op[argc]); @@ -3198,7 +3224,7 @@ constant_arg: else emit_insn (insn); - if (GET_MODE_CLASS (tmode) == MODE_VECTOR_BOOL) + if (TARGET_HAVE_MVE && VALID_MVE_PRED_MODE (tmode)) { rtx HItarget = gen_reg_rtx (HImode); emit_move_insn (HItarget, gen_lowpart (HImode, target)); |