https://gcc.gnu.org/g:6b58ef48245e22dcb1edfa75137ff0b426c9299b
commit r17-6416-g6b58ef48245e22dcb1edfa75137ff0b426c9299b Author: Jiawei <[email protected]> Date: Wed Oct 14 16:48:50 2026 +0800 RISC-V: Add RVV intrinsics for Zvbdota Add the batched dot-product intrinsics with static source-format selection and accumulator VLEN requirements. Limit ci by the physical VLEN when it is known exactly. On scalable targets, check its encoding. Reuse existing naming and expansion helpers, including explicit rounding modes for vfbdota. gcc/ChangeLog: * config/riscv/riscv-vector-builtins-bases.cc (vqwbdota, vfwbdota, vfqwbdota, vfbdota): New expanders. (BASE): Register them. * config/riscv/riscv-vector-builtins-bases.h: Declare new bases. * config/riscv/riscv-vector-builtins-functions.def: Add intrinsics. * config/riscv/riscv-vector-builtins-shapes.cc (bdot_def): New template. (zvbdota_def, vfbdota_def, vfbdota_frm_def): New shapes. (SHAPE): Register Zvbdota shapes. * config/riscv/riscv-vector-builtins-shapes.h: Declare them. * config/riscv/riscv-vector-builtins.cc: Add operand type tables. (get_builtin_partition): Handle Zvbdota extensions. (get_zvbdota_i8_type_index, get_zvbdota_i16_type_index, get_zvbdota_f32_type_index, get_zvbdota_f32_group_type_index, get_zvbdota_bf16_type_index, get_zvbdota_fp8_type_index): New helpers. (rvv_arg_type_info::get_function_type_index): Handle batched operands. (function_checker::require_zvbdota_ci): Check ci bounds and alignment. (validate_instance_type_required_extensions): Check minimum VLEN. * config/riscv/riscv-vector-builtins.def: Add batched operand types. * config/riscv/riscv-vector-builtins.h (RVV_REQUIRE_MIN_VLEN_128, RVV_REQUIRE_MIN_VLEN_256, RVV_REQUIRE_MIN_VLEN_512): New flags. (required_ext, rvv_builtin_partition): Add Zvbdota extensions. (required_ext_to_isa_name, required_extensions_specified): Handle them. (function_checker): Declare require_zvbdota_ci. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/base/zvbdota-acc-lmul-vlen32-fail.c: New test. * gcc.target/riscv/rvv/base/zvbdota-acc-lmul-vlen64-fail.c: New test. * gcc.target/riscv/rvv/base/zvbdota-altfmt-chain.c: New test. * gcc.target/riscv/rvv/base/zvbdota-avlprop.c: New test. * gcc.target/riscv/rvv/base/zvbdota-ci-fixed-max.c: New test. * gcc.target/riscv/rvv/base/zvbdota-ci-invalid.c: New test. * gcc.target/riscv/rvv/base/zvbdota-ci-scalable.c: New test. * gcc.target/riscv/rvv/base/zvbdota-ci-vlen128-invalid.c: New test. * gcc.target/riscv/rvv/base/zvbdota-ci-vlen512-invalid.c: New test. * gcc.target/riscv/rvv/base/zvbdota-ci-vlen512.c: New test. * gcc.target/riscv/rvv/base/zvbdota-intrinsic.c: New test. * gcc.target/riscv/rvv/base/zvbdota-no-overlap.c: New test. * gcc.target/riscv/rvv/base/zvbdota-no-rm-fail.c: New test. * gcc.target/riscv/rvv/base/zvbdota-require-extension.c: New test. Diff: --- gcc/config/riscv/riscv-vector-builtins-bases.cc | 86 ++++ gcc/config/riscv/riscv-vector-builtins-bases.h | 6 + .../riscv/riscv-vector-builtins-functions.def | 34 ++ gcc/config/riscv/riscv-vector-builtins-shapes.cc | 24 + gcc/config/riscv/riscv-vector-builtins-shapes.h | 3 + gcc/config/riscv/riscv-vector-builtins.cc | 497 +++++++++++++++++++++ gcc/config/riscv/riscv-vector-builtins.def | 32 ++ gcc/config/riscv/riscv-vector-builtins.h | 34 ++ .../riscv/rvv/base/zvbdota-acc-lmul-vlen32-fail.c | 59 +++ .../riscv/rvv/base/zvbdota-acc-lmul-vlen64-fail.c | 35 ++ .../riscv/rvv/base/zvbdota-altfmt-chain.c | 17 + .../gcc.target/riscv/rvv/base/zvbdota-avlprop.c | 21 + .../riscv/rvv/base/zvbdota-ci-fixed-max.c | 6 + .../gcc.target/riscv/rvv/base/zvbdota-ci-invalid.c | 33 ++ .../riscv/rvv/base/zvbdota-ci-scalable.c | 23 + .../riscv/rvv/base/zvbdota-ci-vlen128-invalid.c | 31 ++ .../riscv/rvv/base/zvbdota-ci-vlen512-invalid.c | 16 + .../gcc.target/riscv/rvv/base/zvbdota-ci-vlen512.c | 18 + .../gcc.target/riscv/rvv/base/zvbdota-intrinsic.c | 135 ++++++ .../gcc.target/riscv/rvv/base/zvbdota-no-overlap.c | 22 + .../gcc.target/riscv/rvv/base/zvbdota-no-rm-fail.c | 25 ++ .../riscv/rvv/base/zvbdota-require-extension.c | 10 + 22 files changed, 1167 insertions(+) diff --git a/gcc/config/riscv/riscv-vector-builtins-bases.cc b/gcc/config/riscv/riscv-vector-builtins-bases.cc index 642af8213b9a..33c7dace7446 100644 --- a/gcc/config/riscv/riscv-vector-builtins-bases.cc +++ b/gcc/config/riscv/riscv-vector-builtins-bases.cc @@ -2595,6 +2595,80 @@ public: } }; +class vqwbdota : public function_base +{ +public: + bool has_merge_operand_p () const override { return false; } + + rtx expand (function_expander &e) const override + { + bool vs2_unsigned_p + = (e.op_info->args[1].base_type == RVV_BASE_zvbdota_u8_group + || e.op_info->args[1].base_type == RVV_BASE_zvbdota_u16_group); + bool vs1_unsigned_p + = (e.op_info->args[2].base_type == RVV_BASE_zvbdota_u8_src + || e.op_info->args[2].base_type == RVV_BASE_zvbdota_u16_src); + int unspec = vs2_unsigned_p + ? (vs1_unsigned_p ? UNSPEC_VQWBDOTA_UU : UNSPEC_VQWBDOTA_US) + : (vs1_unsigned_p ? UNSPEC_VQWBDOTA_SU : UNSPEC_VQWBDOTA_SS); + return e.use_widen_ternop_insn ( + code_for_pred_vv (unspec, e.vector_mode ())); + } +}; + +class vfwbdota : public function_base +{ +public: + bool has_merge_operand_p () const override { return false; } + + rtx expand (function_expander &e) const override + { + return e.use_widen_ternop_insn ( + code_for_pred_vfwbdota_vv (e.vector_mode ())); + } +}; + +class vfqwbdota : public function_base +{ +public: + bool has_merge_operand_p () const override { return false; } + + rtx expand (function_expander &e) const override + { + bool vs2_e5m2_p + = e.op_info->args[1].base_type == RVV_BASE_zvbdota_f8e5m2_group; + bool vs1_e5m2_p + = e.op_info->args[2].base_type == RVV_BASE_zvbdota_f8e5m2_src; + int unspec = vs2_e5m2_p + ? (vs1_e5m2_p ? UNSPEC_VFQWBDOTA_E5M2_E5M2 + : UNSPEC_VFQWBDOTA_E5M2_E4M3) + : (vs1_e5m2_p ? UNSPEC_VFQWBDOTA_E4M3_E5M2 + : UNSPEC_VFQWBDOTA_E4M3_E4M3); + return e.use_widen_ternop_insn ( + code_for_pred_vv (unspec, e.vector_mode ())); + } +}; + +template<enum frm_op_type FRM_OP = NO_FRM> +class vfbdota : public function_base +{ +public: + bool has_merge_operand_p () const override { return false; } + + bool has_rounding_mode_operand_p () const override + { + return FRM_OP == HAS_FRM; + } + + bool may_require_frm_p () const override { return true; } + + rtx expand (function_expander &e) const override + { + return e.use_widen_ternop_insn ( + code_for_pred_vfbdota_vv (e.vector_mode ())); + } +}; + static constexpr const vsetvl<false> vsetvl_obj; static constexpr const vsetvl<true> vsetvlmax_obj; static constexpr const loadstore<false, LST_UNIT_STRIDE, false> vle_obj; @@ -2931,6 +3005,12 @@ static constexpr const vabda<UNSPEC_VUABDA> vwabdau_obj; static constexpr const vqwdota vqwdota_obj; static constexpr const vfwdota vfwdota_obj; static constexpr const vfqwdota vfqwdota_obj; +/* Zvbdota. */ +static constexpr const vqwbdota vqwbdota_obj; +static constexpr const vfwbdota vfwbdota_obj; +static constexpr const vfqwbdota vfqwbdota_obj; +static constexpr const vfbdota<NO_FRM> vfbdota_obj; +static constexpr const vfbdota<HAS_FRM> vfbdota_frm_obj; /* Declare the function base NAME, pointing it to an instance of class <NAME>_obj. */ @@ -3269,4 +3349,10 @@ BASE (vwabdau) BASE (vqwdota) BASE (vfwdota) BASE (vfqwdota) +/* Zvbdota. */ +BASE (vqwbdota) +BASE (vfwbdota) +BASE (vfqwbdota) +BASE (vfbdota) +BASE (vfbdota_frm) } // end namespace riscv_vector diff --git a/gcc/config/riscv/riscv-vector-builtins-bases.h b/gcc/config/riscv/riscv-vector-builtins-bases.h index 9f4fbdbc636f..8e3e5d9c8500 100644 --- a/gcc/config/riscv/riscv-vector-builtins-bases.h +++ b/gcc/config/riscv/riscv-vector-builtins-bases.h @@ -362,6 +362,12 @@ extern const function_base *const vwabdau; extern const function_base *const vqwdota; extern const function_base *const vfwdota; extern const function_base *const vfqwdota; +/* Zvbdota. */ +extern const function_base *const vqwbdota; +extern const function_base *const vfwbdota; +extern const function_base *const vfqwbdota; +extern const function_base *const vfbdota; +extern const function_base *const vfbdota_frm; } } // end namespace riscv_vector diff --git a/gcc/config/riscv/riscv-vector-builtins-functions.def b/gcc/config/riscv/riscv-vector-builtins-functions.def index cdf755e767d7..eed5ffa0ab99 100644 --- a/gcc/config/riscv/riscv-vector-builtins-functions.def +++ b/gcc/config/riscv/riscv-vector-builtins-functions.def @@ -460,6 +460,40 @@ DEF_RVV_FUNCTION (vfqwdota, zvdota, no_mu_preds, DEF_RVV_FUNCTION (vfqwdota, zvdota, no_mu_preds, zvfqwdota8f_e5m2_e5m2_vv_ops) +#undef REQUIRED_EXTENSIONS +#define REQUIRED_EXTENSIONS ZVQWBDOTA8I_EXT +DEF_RVV_FUNCTION (vqwbdota, zvbdota, full_preds, zvqwbdota8i_ss_vv_ops) +DEF_RVV_FUNCTION (vqwbdota, zvbdota, full_preds, zvqwbdota8i_su_vv_ops) +DEF_RVV_FUNCTION (vqwbdota, zvbdota, full_preds, zvqwbdota8i_us_vv_ops) +DEF_RVV_FUNCTION (vqwbdota, zvbdota, full_preds, zvqwbdota8i_uu_vv_ops) + +#undef REQUIRED_EXTENSIONS +#define REQUIRED_EXTENSIONS ZVQWBDOTA16I_EXT +DEF_RVV_FUNCTION (vqwbdota, zvbdota, full_preds, zvqwbdota16i_ss_vv_ops) +DEF_RVV_FUNCTION (vqwbdota, zvbdota, full_preds, zvqwbdota16i_su_vv_ops) +DEF_RVV_FUNCTION (vqwbdota, zvbdota, full_preds, zvqwbdota16i_us_vv_ops) +DEF_RVV_FUNCTION (vqwbdota, zvbdota, full_preds, zvqwbdota16i_uu_vv_ops) + +#undef REQUIRED_EXTENSIONS +#define REQUIRED_EXTENSIONS ZVFWBDOTA16BF_EXT +DEF_RVV_FUNCTION (vfwbdota, zvbdota, full_preds, zvfwbdota16bf_vv_ops) + +#undef REQUIRED_EXTENSIONS +#define REQUIRED_EXTENSIONS ZVFQWBDOTA8F_EXT +DEF_RVV_FUNCTION (vfqwbdota, zvbdota, full_preds, + zvfqwbdota8f_e4m3_e4m3_vv_ops) +DEF_RVV_FUNCTION (vfqwbdota, zvbdota, full_preds, + zvfqwbdota8f_e4m3_e5m2_vv_ops) +DEF_RVV_FUNCTION (vfqwbdota, zvbdota, full_preds, + zvfqwbdota8f_e5m2_e4m3_vv_ops) +DEF_RVV_FUNCTION (vfqwbdota, zvbdota, full_preds, + zvfqwbdota8f_e5m2_e5m2_vv_ops) + +#undef REQUIRED_EXTENSIONS +#define REQUIRED_EXTENSIONS ZVFBDOTA32F_EXT +DEF_RVV_FUNCTION (vfbdota, vfbdota, full_preds, zvfbdota32f_vv_ops) +DEF_RVV_FUNCTION (vfbdota_frm, vfbdota_frm, full_preds, zvfbdota32f_vv_ops) + #undef REQUIRED_EXTENSIONS #define REQUIRED_EXTENSIONS VECTOR_EXT diff --git a/gcc/config/riscv/riscv-vector-builtins-shapes.cc b/gcc/config/riscv/riscv-vector-builtins-shapes.cc index c7d70edd3537..dea9a2777769 100644 --- a/gcc/config/riscv/riscv-vector-builtins-shapes.cc +++ b/gcc/config/riscv/riscv-vector-builtins-shapes.cc @@ -535,6 +535,27 @@ struct alu_frm_def : public build_frm_base } }; +/* Add the ci immediate check to an existing intrinsic shape. */ +template<typename BASE> +struct bdot_def : public BASE +{ + bool check (function_checker &c) const override + { + bool ok = BASE::check (c); + /* CI follows the accumulator and two sources, and precedes the + optional rounding mode and VL. An invalid call can be shorter. */ + unsigned int trailing_args = c.base->has_rounding_mode_operand_p () ? 2 : 1; + if (c.arg_num () >= 4 + trailing_args) + ok &= c.require_zvbdota_ci (c.arg_num () - trailing_args - 1); + + return ok; + } +}; + +using zvbdota_def = bdot_def<zvdota_def>; +using vfbdota_def = bdot_def<alu_def>; +using vfbdota_frm_def = bdot_def<alu_frm_def>; + /* widen_alu_frm_def class. */ struct widen_alu_frm_def : public build_frm_base { @@ -1466,6 +1487,9 @@ SHAPE(crypto_vv, crypto_vv) SHAPE(crypto_vi, crypto_vi) SHAPE(crypto_vv_no_op_type, crypto_vv_no_op_type) SHAPE (zvdota, zvdota) +SHAPE (zvbdota, zvbdota) +SHAPE (vfbdota, vfbdota) +SHAPE (vfbdota_frm, vfbdota_frm) SHAPE (sf_vqmacc, sf_vqmacc) SHAPE (sf_vfnrclip, sf_vfnrclip) SHAPE(sf_vcix_se, sf_vcix_se) diff --git a/gcc/config/riscv/riscv-vector-builtins-shapes.h b/gcc/config/riscv/riscv-vector-builtins-shapes.h index db3c645fb37b..487413106f65 100644 --- a/gcc/config/riscv/riscv-vector-builtins-shapes.h +++ b/gcc/config/riscv/riscv-vector-builtins-shapes.h @@ -33,6 +33,9 @@ extern const function_shape *const th_indexed_loadstore_width; extern const function_shape *const alu; extern const function_shape *const alu_frm; extern const function_shape *const zvdota; +extern const function_shape *const zvbdota; +extern const function_shape *const vfbdota; +extern const function_shape *const vfbdota_frm; extern const function_shape *const widen_alu; extern const function_shape *const widen_alu_frm; extern const function_shape *const no_mask_policy; diff --git a/gcc/config/riscv/riscv-vector-builtins.cc b/gcc/config/riscv/riscv-vector-builtins.cc index 17d45943ccea..f8cfb813ad3c 100644 --- a/gcc/config/riscv/riscv-vector-builtins.cc +++ b/gcc/config/riscv/riscv-vector-builtins.cc @@ -679,6 +679,68 @@ static const rvv_type_info zvfqwdota8f_e5m2_ops[] = { {VECTOR_TYPE_vfloat8e5m2m8_t, 0}, {NUM_VECTOR_TYPES, 0}}; +static const rvv_type_info zvqwbdota8i_i_ops[] = { + {VECTOR_TYPE_vint32m1_t, RVV_REQUIRE_MIN_VLEN_256}, + {VECTOR_TYPE_vint32m2_t, RVV_REQUIRE_MIN_VLEN_128}, + {VECTOR_TYPE_vint32m4_t, RVV_REQUIRE_MIN_VLEN_64}, + {VECTOR_TYPE_vint32m8_t, 0}, + {NUM_VECTOR_TYPES, 0}}; + +static const rvv_type_info zvqwbdota8i_u_ops[] = { + {VECTOR_TYPE_vuint32m1_t, RVV_REQUIRE_MIN_VLEN_256}, + {VECTOR_TYPE_vuint32m2_t, RVV_REQUIRE_MIN_VLEN_128}, + {VECTOR_TYPE_vuint32m4_t, RVV_REQUIRE_MIN_VLEN_64}, + {VECTOR_TYPE_vuint32m8_t, 0}, + {NUM_VECTOR_TYPES, 0}}; + +static const rvv_type_info zvqwbdota16i_i_ops[] = { + {VECTOR_TYPE_vint64m1_t, RVV_REQUIRE_ELEN_64 | RVV_REQUIRE_MIN_VLEN_512}, + {VECTOR_TYPE_vint64m2_t, RVV_REQUIRE_ELEN_64 | RVV_REQUIRE_MIN_VLEN_256}, + {VECTOR_TYPE_vint64m4_t, RVV_REQUIRE_ELEN_64 | RVV_REQUIRE_MIN_VLEN_128}, + {VECTOR_TYPE_vint64m8_t, RVV_REQUIRE_ELEN_64 | RVV_REQUIRE_MIN_VLEN_64}, + {NUM_VECTOR_TYPES, 0}}; + +static const rvv_type_info zvqwbdota16i_u_ops[] = { + {VECTOR_TYPE_vuint64m1_t, RVV_REQUIRE_ELEN_64 | RVV_REQUIRE_MIN_VLEN_512}, + {VECTOR_TYPE_vuint64m2_t, RVV_REQUIRE_ELEN_64 | RVV_REQUIRE_MIN_VLEN_256}, + {VECTOR_TYPE_vuint64m4_t, RVV_REQUIRE_ELEN_64 | RVV_REQUIRE_MIN_VLEN_128}, + {VECTOR_TYPE_vuint64m8_t, RVV_REQUIRE_ELEN_64 | RVV_REQUIRE_MIN_VLEN_64}, + {NUM_VECTOR_TYPES, 0}}; + +static const rvv_type_info zvfwbdota16bf_ops[] = { + {VECTOR_TYPE_vfloat32m1_t, + RVV_REQUIRE_ELEN_BF_16 | RVV_REQUIRE_ELEN_FP_32 + | RVV_REQUIRE_MIN_VLEN_256}, + {VECTOR_TYPE_vfloat32m2_t, + RVV_REQUIRE_ELEN_BF_16 | RVV_REQUIRE_ELEN_FP_32 + | RVV_REQUIRE_MIN_VLEN_128}, + {VECTOR_TYPE_vfloat32m4_t, + RVV_REQUIRE_ELEN_BF_16 | RVV_REQUIRE_ELEN_FP_32 + | RVV_REQUIRE_MIN_VLEN_64}, + {VECTOR_TYPE_vfloat32m8_t, + RVV_REQUIRE_ELEN_BF_16 | RVV_REQUIRE_ELEN_FP_32}, + {NUM_VECTOR_TYPES, 0}}; + +static const rvv_type_info zvfqwbdota8f_ops[] = { + {VECTOR_TYPE_vfloat32m1_t, + RVV_REQUIRE_ELEN_FP_32 | RVV_REQUIRE_MIN_VLEN_256}, + {VECTOR_TYPE_vfloat32m2_t, + RVV_REQUIRE_ELEN_FP_32 | RVV_REQUIRE_MIN_VLEN_128}, + {VECTOR_TYPE_vfloat32m4_t, + RVV_REQUIRE_ELEN_FP_32 | RVV_REQUIRE_MIN_VLEN_64}, + {VECTOR_TYPE_vfloat32m8_t, RVV_REQUIRE_ELEN_FP_32}, + {NUM_VECTOR_TYPES, 0}}; + +static const rvv_type_info zvfbdota32f_ops[] = { + {VECTOR_TYPE_vfloat32m1_t, + RVV_REQUIRE_ELEN_FP_32 | RVV_REQUIRE_MIN_VLEN_256}, + {VECTOR_TYPE_vfloat32m2_t, + RVV_REQUIRE_ELEN_FP_32 | RVV_REQUIRE_MIN_VLEN_128}, + {VECTOR_TYPE_vfloat32m4_t, + RVV_REQUIRE_ELEN_FP_32 | RVV_REQUIRE_MIN_VLEN_64}, + {VECTOR_TYPE_vfloat32m8_t, RVV_REQUIRE_ELEN_FP_32}, + {NUM_VECTOR_TYPES, 0}}; + static constexpr const rvv_arg_type_info rvv_arg_type_info_end = rvv_arg_type_info (NUM_BASE_TYPES); @@ -813,6 +875,90 @@ static constexpr const rvv_arg_type_info zvdota_fp8_e5m2_args[] rvv_arg_type_info (RVV_BASE_vector), rvv_arg_type_info (RVV_BASE_fp8e5m2_vector), rvv_arg_type_info_end}; +static constexpr const rvv_arg_type_info zvbdota_i8_ss_args[] + = {rvv_arg_type_info (RVV_BASE_vector), + rvv_arg_type_info (RVV_BASE_zvbdota_i8_group), + rvv_arg_type_info (RVV_BASE_zvbdota_i8_src), + rvv_arg_type_info (RVV_BASE_size), rvv_arg_type_info_end}; + +static constexpr const rvv_arg_type_info zvbdota_i8_su_args[] + = {rvv_arg_type_info (RVV_BASE_vector), + rvv_arg_type_info (RVV_BASE_zvbdota_i8_group), + rvv_arg_type_info (RVV_BASE_zvbdota_u8_src), + rvv_arg_type_info (RVV_BASE_size), rvv_arg_type_info_end}; + +static constexpr const rvv_arg_type_info zvbdota_i8_us_args[] + = {rvv_arg_type_info (RVV_BASE_vector), + rvv_arg_type_info (RVV_BASE_zvbdota_u8_group), + rvv_arg_type_info (RVV_BASE_zvbdota_i8_src), + rvv_arg_type_info (RVV_BASE_size), rvv_arg_type_info_end}; + +static constexpr const rvv_arg_type_info zvbdota_i8_uu_args[] + = {rvv_arg_type_info (RVV_BASE_vector), + rvv_arg_type_info (RVV_BASE_zvbdota_u8_group), + rvv_arg_type_info (RVV_BASE_zvbdota_u8_src), + rvv_arg_type_info (RVV_BASE_size), rvv_arg_type_info_end}; + +static constexpr const rvv_arg_type_info zvbdota_i16_ss_args[] + = {rvv_arg_type_info (RVV_BASE_vector), + rvv_arg_type_info (RVV_BASE_zvbdota_i16_group), + rvv_arg_type_info (RVV_BASE_zvbdota_i16_src), + rvv_arg_type_info (RVV_BASE_size), rvv_arg_type_info_end}; + +static constexpr const rvv_arg_type_info zvbdota_i16_su_args[] + = {rvv_arg_type_info (RVV_BASE_vector), + rvv_arg_type_info (RVV_BASE_zvbdota_i16_group), + rvv_arg_type_info (RVV_BASE_zvbdota_u16_src), + rvv_arg_type_info (RVV_BASE_size), rvv_arg_type_info_end}; + +static constexpr const rvv_arg_type_info zvbdota_i16_us_args[] + = {rvv_arg_type_info (RVV_BASE_vector), + rvv_arg_type_info (RVV_BASE_zvbdota_u16_group), + rvv_arg_type_info (RVV_BASE_zvbdota_i16_src), + rvv_arg_type_info (RVV_BASE_size), rvv_arg_type_info_end}; + +static constexpr const rvv_arg_type_info zvbdota_i16_uu_args[] + = {rvv_arg_type_info (RVV_BASE_vector), + rvv_arg_type_info (RVV_BASE_zvbdota_u16_group), + rvv_arg_type_info (RVV_BASE_zvbdota_u16_src), + rvv_arg_type_info (RVV_BASE_size), rvv_arg_type_info_end}; + +static constexpr const rvv_arg_type_info zvbdota_bf16_args[] + = {rvv_arg_type_info (RVV_BASE_vector), + rvv_arg_type_info (RVV_BASE_zvbdota_bf16_group), + rvv_arg_type_info (RVV_BASE_zvbdota_bf16_src), + rvv_arg_type_info (RVV_BASE_size), rvv_arg_type_info_end}; + +static constexpr const rvv_arg_type_info zvbdota_fp8_e4m3_e4m3_args[] + = {rvv_arg_type_info (RVV_BASE_vector), + rvv_arg_type_info (RVV_BASE_zvbdota_f8e4m3_group), + rvv_arg_type_info (RVV_BASE_zvbdota_f8e4m3_src), + rvv_arg_type_info (RVV_BASE_size), rvv_arg_type_info_end}; + +static constexpr const rvv_arg_type_info zvbdota_fp8_e4m3_e5m2_args[] + = {rvv_arg_type_info (RVV_BASE_vector), + rvv_arg_type_info (RVV_BASE_zvbdota_f8e4m3_group), + rvv_arg_type_info (RVV_BASE_zvbdota_f8e5m2_src), + rvv_arg_type_info (RVV_BASE_size), rvv_arg_type_info_end}; + +static constexpr const rvv_arg_type_info zvbdota_fp8_e5m2_e4m3_args[] + = {rvv_arg_type_info (RVV_BASE_vector), + rvv_arg_type_info (RVV_BASE_zvbdota_f8e5m2_group), + rvv_arg_type_info (RVV_BASE_zvbdota_f8e4m3_src), + rvv_arg_type_info (RVV_BASE_size), rvv_arg_type_info_end}; + +static constexpr const rvv_arg_type_info zvbdota_fp8_e5m2_e5m2_args[] + = {rvv_arg_type_info (RVV_BASE_vector), + rvv_arg_type_info (RVV_BASE_zvbdota_f8e5m2_group), + rvv_arg_type_info (RVV_BASE_zvbdota_f8e5m2_src), + rvv_arg_type_info (RVV_BASE_size), rvv_arg_type_info_end}; + +static constexpr const rvv_arg_type_info zvbdota_f32_args[] + = {rvv_arg_type_info (RVV_BASE_vector), + rvv_arg_type_info (RVV_BASE_zvbdota_f32_group), + rvv_arg_type_info (RVV_BASE_zvbdota_f32_src), + rvv_arg_type_info (RVV_BASE_size), rvv_arg_type_info_end}; + /* A list of args for vector_type func (vector_type, vector_type, vector_type) * function. */ static constexpr const rvv_arg_type_info vvv_args[] @@ -1746,6 +1892,90 @@ static constexpr const rvv_op_info zvfqwdota8f_e5m2_e5m2_vv_ops rvv_arg_type_info (RVV_BASE_zvdota_f32_acc), /* Return type. */ zvdota_fp8_e5m2_args /* Args. */}; +static constexpr const rvv_op_info zvqwbdota8i_ss_vv_ops + = {zvqwbdota8i_i_ops, /* Types. */ + OP_TYPE_vv, /* Suffix. */ + rvv_arg_type_info (RVV_BASE_vector), /* Return type. */ + zvbdota_i8_ss_args /* Args. */}; + +static constexpr const rvv_op_info zvqwbdota8i_su_vv_ops + = {zvqwbdota8i_i_ops, /* Types. */ + OP_TYPE_vv, /* Suffix. */ + rvv_arg_type_info (RVV_BASE_vector), /* Return type. */ + zvbdota_i8_su_args /* Args. */}; + +static constexpr const rvv_op_info zvqwbdota8i_us_vv_ops + = {zvqwbdota8i_i_ops, /* Types. */ + OP_TYPE_vv, /* Suffix. */ + rvv_arg_type_info (RVV_BASE_vector), /* Return type. */ + zvbdota_i8_us_args /* Args. */}; + +static constexpr const rvv_op_info zvqwbdota8i_uu_vv_ops + = {zvqwbdota8i_u_ops, /* Types. */ + OP_TYPE_vv, /* Suffix. */ + rvv_arg_type_info (RVV_BASE_vector), /* Return type. */ + zvbdota_i8_uu_args /* Args. */}; + +static constexpr const rvv_op_info zvqwbdota16i_ss_vv_ops + = {zvqwbdota16i_i_ops, /* Types. */ + OP_TYPE_vv, /* Suffix. */ + rvv_arg_type_info (RVV_BASE_vector), /* Return type. */ + zvbdota_i16_ss_args /* Args. */}; + +static constexpr const rvv_op_info zvqwbdota16i_su_vv_ops + = {zvqwbdota16i_i_ops, /* Types. */ + OP_TYPE_vv, /* Suffix. */ + rvv_arg_type_info (RVV_BASE_vector), /* Return type. */ + zvbdota_i16_su_args /* Args. */}; + +static constexpr const rvv_op_info zvqwbdota16i_us_vv_ops + = {zvqwbdota16i_i_ops, /* Types. */ + OP_TYPE_vv, /* Suffix. */ + rvv_arg_type_info (RVV_BASE_vector), /* Return type. */ + zvbdota_i16_us_args /* Args. */}; + +static constexpr const rvv_op_info zvqwbdota16i_uu_vv_ops + = {zvqwbdota16i_u_ops, /* Types. */ + OP_TYPE_vv, /* Suffix. */ + rvv_arg_type_info (RVV_BASE_vector), /* Return type. */ + zvbdota_i16_uu_args /* Args. */}; + +static constexpr const rvv_op_info zvfwbdota16bf_vv_ops + = {zvfwbdota16bf_ops, /* Types. */ + OP_TYPE_vv, /* Suffix. */ + rvv_arg_type_info (RVV_BASE_vector), /* Return type. */ + zvbdota_bf16_args /* Args. */}; + +static constexpr const rvv_op_info zvfqwbdota8f_e4m3_e4m3_vv_ops + = {zvfqwbdota8f_ops, /* Types. */ + OP_TYPE_vv, /* Suffix. */ + rvv_arg_type_info (RVV_BASE_vector), /* Return type. */ + zvbdota_fp8_e4m3_e4m3_args /* Args. */}; + +static constexpr const rvv_op_info zvfqwbdota8f_e4m3_e5m2_vv_ops + = {zvfqwbdota8f_ops, /* Types. */ + OP_TYPE_vv, /* Suffix. */ + rvv_arg_type_info (RVV_BASE_vector), /* Return type. */ + zvbdota_fp8_e4m3_e5m2_args /* Args. */}; + +static constexpr const rvv_op_info zvfqwbdota8f_e5m2_e4m3_vv_ops + = {zvfqwbdota8f_ops, /* Types. */ + OP_TYPE_vv, /* Suffix. */ + rvv_arg_type_info (RVV_BASE_vector), /* Return type. */ + zvbdota_fp8_e5m2_e4m3_args /* Args. */}; + +static constexpr const rvv_op_info zvfqwbdota8f_e5m2_e5m2_vv_ops + = {zvfqwbdota8f_ops, /* Types. */ + OP_TYPE_vv, /* Suffix. */ + rvv_arg_type_info (RVV_BASE_vector), /* Return type. */ + zvbdota_fp8_e5m2_e5m2_args /* Args. */}; + +static constexpr const rvv_op_info zvfbdota32f_vv_ops + = {zvfbdota32f_ops, /* Types. */ + OP_TYPE_vv, /* Suffix. */ + rvv_arg_type_info (RVV_BASE_vector), /* Return type. */ + zvbdota_f32_args /* Args. */}; + /* A static operand information for vector_type func (vector_type, scalar_type, * vector_type) function registration. */ static constexpr const rvv_op_info f_vvfv_ops @@ -3943,6 +4173,16 @@ get_builtin_partition (required_ext ext, const function_instance &instance) return RVV_PARTITION_ZVFWDOTA16BF; case ZVFQWDOTA8F_EXT: return RVV_PARTITION_ZVFQWDOTA8F; + case ZVQWBDOTA8I_EXT: + return RVV_PARTITION_ZVQWBDOTA8I; + case ZVQWBDOTA16I_EXT: + return RVV_PARTITION_ZVQWBDOTA16I; + case ZVFWBDOTA16BF_EXT: + return RVV_PARTITION_ZVFWBDOTA16BF; + case ZVFQWBDOTA8F_EXT: + return RVV_PARTITION_ZVFQWBDOTA8F; + case ZVFBDOTA32F_EXT: + return RVV_PARTITION_ZVFBDOTA32F; case XSFVQMACCQOQ_EXT: return RVV_PARTITION_XSFVQMACCQOQ; case XSFVQMACCDOD_EXT: @@ -4507,9 +4747,188 @@ rvv_arg_type_info::get_scalar_float_type (vector_type_index type_idx) const return NULL_TREE; } +static vector_type_index +get_zvbdota_i8_type_index (vector_type_index type_idx, bool unsigned_p, + bool group_p) +{ + switch (type_idx) + { + case VECTOR_TYPE_vint32m1_t: + case VECTOR_TYPE_vuint32m1_t: + case VECTOR_TYPE_vint32m2_t: + case VECTOR_TYPE_vuint32m2_t: + case VECTOR_TYPE_vint32m4_t: + case VECTOR_TYPE_vuint32m4_t: + case VECTOR_TYPE_vint32m8_t: + case VECTOR_TYPE_vuint32m8_t: + if (unsigned_p) + return group_p ? VECTOR_TYPE_vuint8m8_t : VECTOR_TYPE_vuint8m1_t; + return group_p ? VECTOR_TYPE_vint8m8_t : VECTOR_TYPE_vint8m1_t; + + default: + return VECTOR_TYPE_INVALID; + } +} + +static vector_type_index +get_zvbdota_i16_type_index (vector_type_index type_idx, bool unsigned_p, + bool group_p) +{ + switch (type_idx) + { + case VECTOR_TYPE_vint64m1_t: + case VECTOR_TYPE_vuint64m1_t: + case VECTOR_TYPE_vint64m2_t: + case VECTOR_TYPE_vuint64m2_t: + case VECTOR_TYPE_vint64m4_t: + case VECTOR_TYPE_vuint64m4_t: + case VECTOR_TYPE_vint64m8_t: + case VECTOR_TYPE_vuint64m8_t: + if (unsigned_p) + return group_p ? VECTOR_TYPE_vuint16m8_t : VECTOR_TYPE_vuint16m1_t; + return group_p ? VECTOR_TYPE_vint16m8_t : VECTOR_TYPE_vint16m1_t; + + default: + return VECTOR_TYPE_INVALID; + } +} + +static vector_type_index +get_zvbdota_f32_type_index (vector_type_index type_idx) +{ + switch (type_idx) + { + case VECTOR_TYPE_vfloat32m1_t: + case VECTOR_TYPE_vfloat32m2_t: + case VECTOR_TYPE_vfloat32m4_t: + case VECTOR_TYPE_vfloat32m8_t: + return VECTOR_TYPE_vfloat32m1_t; + + default: + return VECTOR_TYPE_INVALID; + } +} + +static vector_type_index +get_zvbdota_f32_group_type_index (vector_type_index type_idx) +{ + switch (type_idx) + { + case VECTOR_TYPE_vfloat32m1_t: + case VECTOR_TYPE_vfloat32m2_t: + case VECTOR_TYPE_vfloat32m4_t: + case VECTOR_TYPE_vfloat32m8_t: + return VECTOR_TYPE_vfloat32m8_t; + + default: + return VECTOR_TYPE_INVALID; + } +} + +static vector_type_index +get_zvbdota_bf16_type_index (vector_type_index type_idx, bool group_p) +{ + switch (type_idx) + { + case VECTOR_TYPE_vfloat32m1_t: + case VECTOR_TYPE_vfloat32m2_t: + case VECTOR_TYPE_vfloat32m4_t: + case VECTOR_TYPE_vfloat32m8_t: + return group_p ? VECTOR_TYPE_vbfloat16m8_t : VECTOR_TYPE_vbfloat16m1_t; + + default: + return VECTOR_TYPE_INVALID; + } +} + +static vector_type_index +get_zvbdota_fp8_type_index (vector_type_index type_idx, bool e5m2_p, + bool group_p) +{ + switch (type_idx) + { + case VECTOR_TYPE_vfloat32m1_t: + case VECTOR_TYPE_vfloat32m2_t: + case VECTOR_TYPE_vfloat32m4_t: + case VECTOR_TYPE_vfloat32m8_t: + if (e5m2_p) + return group_p ? VECTOR_TYPE_vfloat8e5m2m8_t + : VECTOR_TYPE_vfloat8e5m2m1_t; + return group_p ? VECTOR_TYPE_vfloat8e4m3m8_t + : VECTOR_TYPE_vfloat8e4m3m1_t; + + default: + return VECTOR_TYPE_INVALID; + } +} + vector_type_index rvv_arg_type_info::get_function_type_index (vector_type_index type_idx) const { + vector_type_index function_type_idx = VECTOR_TYPE_INVALID; + switch (base_type) + { + case RVV_BASE_zvbdota_i8_group: + function_type_idx = get_zvbdota_i8_type_index (type_idx, false, true); + break; + case RVV_BASE_zvbdota_u8_group: + function_type_idx = get_zvbdota_i8_type_index (type_idx, true, true); + break; + case RVV_BASE_zvbdota_i8_src: + function_type_idx = get_zvbdota_i8_type_index (type_idx, false, false); + break; + case RVV_BASE_zvbdota_u8_src: + function_type_idx = get_zvbdota_i8_type_index (type_idx, true, false); + break; + case RVV_BASE_zvbdota_i16_group: + function_type_idx = get_zvbdota_i16_type_index (type_idx, false, true); + break; + case RVV_BASE_zvbdota_u16_group: + function_type_idx = get_zvbdota_i16_type_index (type_idx, true, true); + break; + case RVV_BASE_zvbdota_i16_src: + function_type_idx = get_zvbdota_i16_type_index (type_idx, false, false); + break; + case RVV_BASE_zvbdota_u16_src: + function_type_idx = get_zvbdota_i16_type_index (type_idx, true, false); + break; + case RVV_BASE_zvbdota_bf16_group: + function_type_idx = get_zvbdota_bf16_type_index (type_idx, true); + break; + case RVV_BASE_zvbdota_bf16_src: + function_type_idx = get_zvbdota_bf16_type_index (type_idx, false); + break; + case RVV_BASE_zvbdota_f8e4m3_group: + function_type_idx = get_zvbdota_fp8_type_index (type_idx, false, true); + break; + case RVV_BASE_zvbdota_f8e4m3_src: + function_type_idx = get_zvbdota_fp8_type_index (type_idx, false, false); + break; + case RVV_BASE_zvbdota_f8e5m2_group: + function_type_idx = get_zvbdota_fp8_type_index (type_idx, true, true); + break; + case RVV_BASE_zvbdota_f8e5m2_src: + function_type_idx = get_zvbdota_fp8_type_index (type_idx, true, false); + break; + case RVV_BASE_zvbdota_f32_group: + function_type_idx = get_zvbdota_f32_group_type_index (type_idx); + break; + case RVV_BASE_zvbdota_f32_src: + function_type_idx = get_zvbdota_f32_type_index (type_idx); + break; + default: + break; + } + + if (function_type_idx == VECTOR_TYPE_INVALID + && base_type >= RVV_BASE_zvbdota_i8_group + && base_type <= RVV_BASE_zvbdota_f32_src) + return NUM_VECTOR_TYPES; + + if (function_type_idx != VECTOR_TYPE_INVALID) + return builtin_types[function_type_idx].vector ? function_type_idx + : NUM_VECTOR_TYPES; + tree type = builtin_types[function_types[type_idx].type_indexes[base_type]].vector; return type ? function_types[type_idx].type_indexes[base_type] @@ -5614,6 +6033,52 @@ function_checker::require_immediate_range_or (unsigned int argno, return true; } +/* Check that argument ARGNO is a valid Zvbdota ci immediate. */ +bool +function_checker::require_zvbdota_ci (unsigned int argno) const +{ + gcc_assert (argno >= 3 && argno < m_nargs); + + tree arg = m_args[argno]; + if (TREE_CODE (arg) != INTEGER_CST) + { + report_non_ice (argno); + return false; + } + + widest_int actual = wi::to_widest (arg); + if (actual < 0 || actual > 56 || actual.to_shwi () % 8 != 0) + { + error_at (location, + "argument %d of %qE must be a constant multiple of 8 in the " + "range 0 to 56", + argno + 1, fndecl); + return false; + } + + /* CI selects eight accumulator elements, independently of VL and the + compiler accumulator type's LMUL. Only use an exact VLEN here: a + scalable target can guard larger offsets using the runtime VLEN. */ + machine_mode acc_mode = arg_mode (argno - 3); + unsigned int vlen; + if (VECTOR_MODE_P (acc_mode) && BITS_PER_RISCV_VECTOR.is_constant (&vlen)) + { + unsigned int eew = GET_MODE_BITSIZE (GET_MODE_INNER (acc_mode)); + unsigned int max_ci = vlen > 8 * eew ? vlen / eew - 8 : 0; + max_ci = MIN (max_ci, 56U); + if (actual.to_shwi () > max_ci) + { + error_at (location, + "argument %d of %qE must be in the range 0 to %u " + "for a %u-bit VLEN", + argno + 1, fndecl, max_ci, vlen); + return false; + } + } + + return true; +} + /* Perform semantic checks on the call. Return true if the call is valid, otherwise report a suitable error. */ bool @@ -6032,6 +6497,38 @@ validate_instance_type_required_extensions (const rvv_type_info type, return false; } + if ((exts & RVV_REQUIRE_MIN_VLEN_64) && TARGET_MIN_VLEN < 64) + { + error_at (location, + "built-in function %qE requires the zvl64b ISA extension", + fndecl); + return false; + } + + if ((exts & RVV_REQUIRE_MIN_VLEN_128) && TARGET_MIN_VLEN < 128) + { + error_at (location, + "built-in function %qE requires the zvl128b ISA extension", + fndecl); + return false; + } + + if ((exts & RVV_REQUIRE_MIN_VLEN_256) && TARGET_MIN_VLEN < 256) + { + error_at (location, + "built-in function %qE requires the zvl256b ISA extension", + fndecl); + return false; + } + + if ((exts & RVV_REQUIRE_MIN_VLEN_512) && TARGET_MIN_VLEN < 512) + { + error_at (location, + "built-in function %qE requires the zvl512b ISA extension", + fndecl); + return false; + } + return true; } diff --git a/gcc/config/riscv/riscv-vector-builtins.def b/gcc/config/riscv/riscv-vector-builtins.def index 6ef1c9720594..07de4f161c80 100644 --- a/gcc/config/riscv/riscv-vector-builtins.def +++ b/gcc/config/riscv/riscv-vector-builtins.def @@ -794,6 +794,38 @@ DEF_RVV_BASE_TYPE (tuple_subpart, get_tuple_subpart_type (type_idx)) DEF_RVV_BASE_TYPE (xfqf_float, get_xfqf_float_type (type_idx)) DEF_RVV_BASE_TYPE (scalar_float, get_scalar_float_type (type_idx)) DEF_RVV_BASE_TYPE (void_const_ptr, const_ptr_type_node) +DEF_RVV_BASE_TYPE (zvbdota_i8_group, + builtin_types[get_function_type_index (type_idx)].vector) +DEF_RVV_BASE_TYPE (zvbdota_u8_group, + builtin_types[get_function_type_index (type_idx)].vector) +DEF_RVV_BASE_TYPE (zvbdota_i8_src, + builtin_types[get_function_type_index (type_idx)].vector) +DEF_RVV_BASE_TYPE (zvbdota_u8_src, + builtin_types[get_function_type_index (type_idx)].vector) +DEF_RVV_BASE_TYPE (zvbdota_i16_group, + builtin_types[get_function_type_index (type_idx)].vector) +DEF_RVV_BASE_TYPE (zvbdota_u16_group, + builtin_types[get_function_type_index (type_idx)].vector) +DEF_RVV_BASE_TYPE (zvbdota_i16_src, + builtin_types[get_function_type_index (type_idx)].vector) +DEF_RVV_BASE_TYPE (zvbdota_u16_src, + builtin_types[get_function_type_index (type_idx)].vector) +DEF_RVV_BASE_TYPE (zvbdota_bf16_group, + builtin_types[get_function_type_index (type_idx)].vector) +DEF_RVV_BASE_TYPE (zvbdota_bf16_src, + builtin_types[get_function_type_index (type_idx)].vector) +DEF_RVV_BASE_TYPE (zvbdota_f8e4m3_group, + builtin_types[get_function_type_index (type_idx)].vector) +DEF_RVV_BASE_TYPE (zvbdota_f8e4m3_src, + builtin_types[get_function_type_index (type_idx)].vector) +DEF_RVV_BASE_TYPE (zvbdota_f8e5m2_group, + builtin_types[get_function_type_index (type_idx)].vector) +DEF_RVV_BASE_TYPE (zvbdota_f8e5m2_src, + builtin_types[get_function_type_index (type_idx)].vector) +DEF_RVV_BASE_TYPE (zvbdota_f32_group, + builtin_types[get_function_type_index (type_idx)].vector) +DEF_RVV_BASE_TYPE (zvbdota_f32_src, + builtin_types[get_function_type_index (type_idx)].vector) DEF_RVV_VXRM_ENUM (RNU, VXRM_RNU) DEF_RVV_VXRM_ENUM (RNE, VXRM_RNE) diff --git a/gcc/config/riscv/riscv-vector-builtins.h b/gcc/config/riscv/riscv-vector-builtins.h index 9bae37e40561..9b36f7faef73 100644 --- a/gcc/config/riscv/riscv-vector-builtins.h +++ b/gcc/config/riscv/riscv-vector-builtins.h @@ -111,6 +111,9 @@ static const unsigned int CP_WRITE_CSR = 1U << 5; #define RVV_REQUIRE_ELEN_FP_16 (1 << 6) /* Require FP ELEN >= 32. */ #define RVV_REQUIRE_ELEN_BF_16 (1 << 7) /* Require BF16. */ #define RVV_REQUIRE_ZVFOFP8MIN (1 << 8) /* Require ZVFOFP8MIN extension. */ +#define RVV_REQUIRE_MIN_VLEN_128 (1 << 9) /* Require VLEN >= 128. */ +#define RVV_REQUIRE_MIN_VLEN_256 (1 << 10) /* Require VLEN >= 256. */ +#define RVV_REQUIRE_MIN_VLEN_512 (1 << 11) /* Require VLEN >= 512. */ /* Enumerates the required extensions. */ enum required_ext @@ -136,6 +139,11 @@ enum required_ext ZVQWDOTA16I_EXT, /* Zvqwdota16i extension. */ ZVFWDOTA16BF_EXT, /* Zvfwdota16bf extension. */ ZVFQWDOTA8F_EXT, /* Zvfqwdota8f extension. */ + ZVQWBDOTA8I_EXT, /* Zvqwbdota8i extension. */ + ZVQWBDOTA16I_EXT, /* Zvqwbdota16i extension. */ + ZVFWBDOTA16BF_EXT, /* Zvfwbdota16bf extension. */ + ZVFQWBDOTA8F_EXT, /* Zvfqwbdota8f extension. */ + ZVFBDOTA32F_EXT, /* Zvfbdota32f extension. */ XSFVQMACCQOQ_EXT, /* XSFVQMACCQOQ extension */ XSFVQMACCDOD_EXT, /* XSFVQMACCDOD extension */ XSFVFNRCLIPXFQF_EXT, /* XSFVFNRCLIPXFQF extension */ @@ -173,6 +181,11 @@ enum rvv_builtin_partition RVV_PARTITION_ZVQWDOTA16I, RVV_PARTITION_ZVFWDOTA16BF, RVV_PARTITION_ZVFQWDOTA8F, + RVV_PARTITION_ZVQWBDOTA8I, + RVV_PARTITION_ZVQWBDOTA16I, + RVV_PARTITION_ZVFWBDOTA16BF, + RVV_PARTITION_ZVFQWBDOTA8F, + RVV_PARTITION_ZVFBDOTA32F, RVV_PARTITION_XSFVQMACCQOQ, RVV_PARTITION_XSFVQMACCDOD, RVV_PARTITION_XSFVFNRCLIPXFQF, @@ -238,6 +251,16 @@ static inline const char * required_ext_to_isa_name (enum required_ext required) return "zvfwdota16bf"; case ZVFQWDOTA8F_EXT: return "zvfqwdota8f"; + case ZVQWBDOTA8I_EXT: + return "zvqwbdota8i"; + case ZVQWBDOTA16I_EXT: + return "zvqwbdota16i"; + case ZVFWBDOTA16BF_EXT: + return "zvfwbdota16bf"; + case ZVFQWBDOTA8F_EXT: + return "zvfqwbdota8f"; + case ZVFBDOTA32F_EXT: + return "zvfbdota32f"; case XSFVQMACCQOQ_EXT: return "xsfvqmaccqoq"; case XSFVQMACCDOD_EXT: @@ -307,6 +330,16 @@ static inline bool required_extensions_specified (enum required_ext required) return TARGET_ZVFWDOTA16BF; case ZVFQWDOTA8F_EXT: return TARGET_ZVFQWDOTA8F; + case ZVQWBDOTA8I_EXT: + return TARGET_ZVQWBDOTA8I; + case ZVQWBDOTA16I_EXT: + return TARGET_ZVQWBDOTA16I; + case ZVFWBDOTA16BF_EXT: + return TARGET_ZVFWBDOTA16BF; + case ZVFQWBDOTA8F_EXT: + return TARGET_ZVFQWBDOTA8F; + case ZVFBDOTA32F_EXT: + return TARGET_ZVFBDOTA32F; case XSFVQMACCQOQ_EXT: return TARGET_XSFVQMACCQOQ; case XSFVQMACCDOD_EXT: @@ -681,6 +714,7 @@ public: bool require_immediate (unsigned int, HOST_WIDE_INT, HOST_WIDE_INT) const; bool require_immediate_range_or (unsigned int, HOST_WIDE_INT, HOST_WIDE_INT, HOST_WIDE_INT) const; + bool require_zvbdota_ci (unsigned int) const; private: bool require_immediate_range (unsigned int, HOST_WIDE_INT, diff --git a/gcc/testsuite/gcc.target/riscv/rvv/base/zvbdota-acc-lmul-vlen32-fail.c b/gcc/testsuite/gcc.target/riscv/rvv/base/zvbdota-acc-lmul-vlen32-fail.c new file mode 100644 index 000000000000..db72ec4ba18a --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/base/zvbdota-acc-lmul-vlen32-fail.c @@ -0,0 +1,59 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc_zvqwbdota8i_zvfwbdota16bf_zvfbfmin_zvfqwbdota8f_zvfbdota32f -mabi=lp64d -O2" } */ + +#include "riscv_vector.h" + +vuint32m1_t +test_vqwbdota_u32m1 (vuint32m1_t vd, vuint8m8_t vs2, vuint8m1_t vs1, + size_t vl) +{ + return __riscv_vqwbdota_vv_u8m8_u8m1_u32m1 (vd, vs2, vs1, 0, vl); + /* { dg-error "requires the zvl256b ISA extension" "" { target *-*-* } .-1 } */ +} + +vuint32m2_t +test_vqwbdota_u32m2 (vuint32m2_t vd, vuint8m8_t vs2, vuint8m1_t vs1, + size_t vl) +{ + return __riscv_vqwbdota_vv_u8m8_u8m1_u32m2 (vd, vs2, vs1, 0, vl); + /* { dg-error "requires the zvl128b ISA extension" "" { target *-*-* } .-1 } */ +} + +vuint32m4_t +test_vqwbdota_u32m4 (vuint32m4_t vd, vuint8m8_t vs2, vuint8m1_t vs1, + size_t vl) +{ + return __riscv_vqwbdota_vv_u8m8_u8m1_u32m4 (vd, vs2, vs1, 0, vl); + /* { dg-error "requires the zvl64b ISA extension" "" { target *-*-* } .-1 } */ +} + +vuint32m8_t +test_vqwbdota_u32m8 (vuint32m8_t vd, vuint8m8_t vs2, vuint8m1_t vs1, + size_t vl) +{ + return __riscv_vqwbdota_vv_u8m8_u8m1_u32m8 (vd, vs2, vs1, 0, vl); +} + +vfloat32m4_t +test_vfwbdota_f32m4 (vfloat32m4_t vd, vbfloat16m8_t vs2, + vbfloat16m1_t vs1, size_t vl) +{ + return __riscv_vfwbdota_vv_bf16m8_bf16m1_f32m4 (vd, vs2, vs1, 0, vl); + /* { dg-error "requires the zvl64b ISA extension" "" { target *-*-* } .-1 } */ +} + +vfloat32m4_t +test_vfqwbdota_f32m4 (vfloat32m4_t vd, vfloat8e4m3m8_t vs2, + vfloat8e4m3m1_t vs1, size_t vl) +{ + return __riscv_vfqwbdota_vv_f8e4m3m8_f8e4m3m1_f32m4 (vd, vs2, vs1, 0, vl); + /* { dg-error "requires the zvl64b ISA extension" "" { target *-*-* } .-1 } */ +} + +vfloat32m4_t +test_vfbdota_f32m4 (vfloat32m4_t vd, vfloat32m8_t vs2, + vfloat32m1_t vs1, size_t vl) +{ + return __riscv_vfbdota_vv_f32m4 (vd, vs2, vs1, 0, vl); + /* { dg-error "requires the zvl64b ISA extension" "" { target *-*-* } .-1 } */ +} diff --git a/gcc/testsuite/gcc.target/riscv/rvv/base/zvbdota-acc-lmul-vlen64-fail.c b/gcc/testsuite/gcc.target/riscv/rvv/base/zvbdota-acc-lmul-vlen64-fail.c new file mode 100644 index 000000000000..ae76d599a789 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/base/zvbdota-acc-lmul-vlen64-fail.c @@ -0,0 +1,35 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gc_zvqwbdota16i_zvl64b -mabi=lp64d -O2" } */ + +#include "riscv_vector.h" + +vuint64m1_t +test_vqwbdota_u64m1 (vuint64m1_t vd, vuint16m8_t vs2, vuint16m1_t vs1, + size_t vl) +{ + return __riscv_vqwbdota_vv_u16m8_u16m1_u64m1 (vd, vs2, vs1, 0, vl); + /* { dg-error "requires the zvl512b ISA extension" "" { target *-*-* } .-1 } */ +} + +vuint64m2_t +test_vqwbdota_u64m2 (vuint64m2_t vd, vuint16m8_t vs2, vuint16m1_t vs1, + size_t vl) +{ + return __riscv_vqwbdota_vv_u16m8_u16m1_u64m2 (vd, vs2, vs1, 0, vl); + /* { dg-error "requires the zvl256b ISA extension" "" { target *-*-* } .-1 } */ +} + +vuint64m4_t +test_vqwbdota_u64m4 (vuint64m4_t vd, vuint16m8_t vs2, vuint16m1_t vs1, + size_t vl) +{ + return __riscv_vqwbdota_vv_u16m8_u16m1_u64m4 (vd, vs2, vs1, 0, vl); + /* { dg-error "requires the zvl128b ISA extension" "" { target *-*-* } .-1 } */ +} + +vuint64m8_t +test_vqwbdota_u64m8 (vuint64m8_t vd, vuint16m8_t vs2, vuint16m1_t vs1, + size_t vl) +{ + return __riscv_vqwbdota_vv_u16m8_u16m1_u64m8 (vd, vs2, vs1, 0, vl); +} diff --git a/gcc/testsuite/gcc.target/riscv/rvv/base/zvbdota-altfmt-chain.c b/gcc/testsuite/gcc.target/riscv/rvv/base/zvbdota-altfmt-chain.c new file mode 100644 index 000000000000..fc43a9ba9958 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/base/zvbdota-altfmt-chain.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv_zvqwbdota8i_zvl512b -mabi=lp64d -O2" } */ + +#include "riscv_vector.h" + +vint32m1_t +test_altfmt_chain (vint32m1_t acc, vint8m8_t a, vint8m1_t b, + vuint8m1_t c, size_t vl) +{ + acc = __riscv_vqwbdota_vv_i8m8_i8m1_i32m1 (acc, a, b, 0, vl); + acc = __riscv_vqwbdota_vv_i8m8_u8m1_i32m1 (acc, a, c, 0, vl); + return __riscv_vqwbdota_vv_i8m8_i8m1_i32m1 (acc, a, b, 0, vl); +} + +/* { dg-final { scan-assembler-times {vqwbdotas\.vv} 3 } } */ +/* { dg-final { scan-assembler-times {e8alt,\s*m1,} 2 } } */ +/* { dg-final { scan-assembler-times {e8,\s*m1,} 1 } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/base/zvbdota-avlprop.c b/gcc/testsuite/gcc.target/riscv/rvv/base/zvbdota-avlprop.c new file mode 100644 index 000000000000..bad245f00e40 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/base/zvbdota-avlprop.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv_zvfbdota32f_zvl256b -mabi=lp64d -mrvv-vector-bits=zvl -O2 -fdump-rtl-avlprop-details" } */ + +#include "riscv_vector.h" + +typedef vfloat32m1_t fixed_f32m1 + __attribute__ ((riscv_rvv_vector_bits (256))); + +/* The dot product reads all eight accumulator elements even with VL=1. */ +vfloat32m1_t +test_acc_producer (fixed_f32m1 a, fixed_f32m1 b, vfloat32m8_t group, + vfloat32m1_t source) +{ + fixed_f32m1 acc = a + b; + return __riscv_vfbdota_vv_f32m1 (acc, group, source, 0, 1); +} + +/* { dg-final { scan-assembler {vfadd\.vv} } } */ +/* { dg-final { scan-assembler {vfbdota\.vv} } } */ +/* { dg-final { scan-assembler {vsetivli\s+zero,8,e32,m1,} } } */ +/* { dg-final { scan-rtl-dump-not {Propagating AVL: \(const_int 1 } "avlprop" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/base/zvbdota-ci-fixed-max.c b/gcc/testsuite/gcc.target/riscv/rvv/base/zvbdota-ci-fixed-max.c new file mode 100644 index 000000000000..826dc70ef9b8 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/base/zvbdota-ci-fixed-max.c @@ -0,0 +1,6 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv_zvqwbdota8i_zvqwbdota16i_zvfwbdota16bf_zvfqwbdota8f_zvfbdota32f_zvfbfmin_zvl4096b -mabi=lp64d -mrvv-vector-bits=zvl -O2" } */ + +#include "zvbdota-intrinsic.c" + +/* { dg-final { scan-assembler {vfbdota\.vv[^\n]*56} } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/base/zvbdota-ci-invalid.c b/gcc/testsuite/gcc.target/riscv/rvv/base/zvbdota-ci-invalid.c new file mode 100644 index 000000000000..adda41a1ff98 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/base/zvbdota-ci-invalid.c @@ -0,0 +1,33 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv_zvqwbdota8i -mabi=lp64d -O2" } */ + +#include "riscv_vector.h" + +vuint32m8_t +test_ci_4 (vuint32m8_t vd, vuint8m8_t vs2, vuint8m1_t vs1, size_t vl) +{ + return __riscv_vqwbdota_vv_u8m8_u8m1_u32m8 (vd, vs2, vs1, 4, vl); + /* { dg-error "argument 4 of '__riscv_vqwbdota_vv_u8m8_u8m1_u32m8' must be a constant multiple of 8 in the range 0 to 56" "" { target *-*-* } .-1 } */ +} + +vint32m8_t +test_ci_64 (vint32m8_t vd, vuint8m8_t vs2, vint8m1_t vs1, size_t vl) +{ + return __riscv_vqwbdota_vv_u8m8_i8m1_i32m8 (vd, vs2, vs1, 64, vl); + /* { dg-error "argument 4 of '__riscv_vqwbdota_vv_u8m8_i8m1_i32m8' must be a constant multiple of 8 in the range 0 to 56" "" { target *-*-* } .-1 } */ +} + +vint32m8_t +test_ci_minus_8 (vint32m8_t vd, vint8m8_t vs2, vuint8m1_t vs1, size_t vl) +{ + return __riscv_vqwbdota_vv_i8m8_u8m1_i32m8 (vd, vs2, vs1, -8, vl); + /* { dg-error "argument 4 of '__riscv_vqwbdota_vv_i8m8_u8m1_i32m8' must be a constant multiple of 8 in the range 0 to 56" "" { target *-*-* } .-1 } */ +} + +vuint32m8_t +test_ci_variable (vuint32m8_t vd, vuint8m8_t vs2, vuint8m1_t vs1, + size_t ci, size_t vl) +{ + return __riscv_vqwbdota_vv_u8m8_u8m1_u32m8 (vd, vs2, vs1, ci, vl); + /* { dg-error "argument 4 of .* must be an integer constant expression" "" { target *-*-* } .-1 } */ +} diff --git a/gcc/testsuite/gcc.target/riscv/rvv/base/zvbdota-ci-scalable.c b/gcc/testsuite/gcc.target/riscv/rvv/base/zvbdota-ci-scalable.c new file mode 100644 index 000000000000..127731e13ee5 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/base/zvbdota-ci-scalable.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv_zvqwbdota8i_zvqwbdota16i -mabi=lp64d -mrvv-vector-bits=scalable -O2" } */ + +#include "riscv_vector.h" + +/* The minimum VLEN is not the runtime VLEN. A caller can guard CI=56. */ +vuint32m8_t +test_u32 (vuint32m8_t acc, vuint8m8_t a, vuint8m1_t b, size_t vl) +{ + if (__riscv_vlenb () < 256) + return acc; + return __riscv_vqwbdota_vv_u8m8_u8m1_u32m8 (acc, a, b, 56, vl); +} + +vuint64m8_t +test_u64 (vuint64m8_t acc, vuint16m8_t a, vuint16m1_t b, size_t vl) +{ + if (__riscv_vlenb () < 512) + return acc; + return __riscv_vqwbdota_vv_u16m8_u16m1_u64m8 (acc, a, b, 56, vl); +} + +/* { dg-final { scan-assembler-times {vqwbdotau\.vv} 2 } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/base/zvbdota-ci-vlen128-invalid.c b/gcc/testsuite/gcc.target/riscv/rvv/base/zvbdota-ci-vlen128-invalid.c new file mode 100644 index 000000000000..2e71c43d9596 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/base/zvbdota-ci-vlen128-invalid.c @@ -0,0 +1,31 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv_zvqwbdota8i_zvqwbdota16i_zvfbdota32f -mabi=lp64d -mrvv-vector-bits=zvl -O2" } */ + +#include "riscv_vector.h" + +/* Even an m8 accumulator cannot enlarge the hardware destination group. */ +vuint32m8_t +test_u32 (vuint32m8_t acc, vuint8m8_t a, vuint8m1_t b, size_t vl) +{ + return __riscv_vqwbdota_vv_u8m8_u8m1_u32m8 (acc, a, b, 8, vl); /* { dg-error {range 0 to 0 for a 128-bit VLEN} } */ +} + +vuint64m8_t +test_u64 (vuint64m8_t acc, vuint16m8_t a, vuint16m1_t b, size_t vl) +{ + return __riscv_vqwbdota_vv_u16m8_u16m1_u64m8 (acc, a, b, 8, vl); /* { dg-error {range 0 to 0 for a 128-bit VLEN} } */ +} + +vfloat32m8_t +test_masked (vbool4_t mask, vfloat32m8_t acc, vfloat32m8_t a, + vfloat32m1_t b, size_t vl) +{ + return __riscv_vfbdota (mask, acc, a, b, 8, vl); /* { dg-error {range 0 to 0 for a 128-bit VLEN} } */ +} + +vfloat32m8_t +test_masked_rm (vbool4_t mask, vfloat32m8_t acc, vfloat32m8_t a, + vfloat32m1_t b, size_t vl) +{ + return __riscv_vfbdota (mask, acc, a, b, 8, __RISCV_FRM_RNE, vl); /* { dg-error {range 0 to 0 for a 128-bit VLEN} } */ +} diff --git a/gcc/testsuite/gcc.target/riscv/rvv/base/zvbdota-ci-vlen512-invalid.c b/gcc/testsuite/gcc.target/riscv/rvv/base/zvbdota-ci-vlen512-invalid.c new file mode 100644 index 000000000000..3f373176427e --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/base/zvbdota-ci-vlen512-invalid.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv_zvqwbdota8i_zvqwbdota16i_zvl512b -mabi=lp64d -mrvv-vector-bits=zvl -O2" } */ + +#include "riscv_vector.h" + +vuint32m1_t +test_u32 (vuint32m1_t acc, vuint8m8_t a, vuint8m1_t b, size_t vl) +{ + return __riscv_vqwbdota_vv_u8m8_u8m1_u32m1 (acc, a, b, 16, vl); /* { dg-error {range 0 to 8 for a 512-bit VLEN} } */ +} + +vuint64m1_t +test_u64 (vuint64m1_t acc, vuint16m8_t a, vuint16m1_t b, size_t vl) +{ + return __riscv_vqwbdota_vv_u16m8_u16m1_u64m1 (acc, a, b, 8, vl); /* { dg-error {range 0 to 0 for a 512-bit VLEN} } */ +} diff --git a/gcc/testsuite/gcc.target/riscv/rvv/base/zvbdota-ci-vlen512.c b/gcc/testsuite/gcc.target/riscv/rvv/base/zvbdota-ci-vlen512.c new file mode 100644 index 000000000000..a078ff0338dd --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/base/zvbdota-ci-vlen512.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv_zvqwbdota8i_zvqwbdota16i_zvl512b -mabi=lp64d -mrvv-vector-bits=zvl -O2" } */ + +#include "riscv_vector.h" + +vuint32m1_t +test_u32 (vuint32m1_t acc, vuint8m8_t a, vuint8m1_t b, size_t vl) +{ + return __riscv_vqwbdota_vv_u8m8_u8m1_u32m1 (acc, a, b, 8, vl); +} + +vuint64m1_t +test_u64 (vuint64m1_t acc, vuint16m8_t a, vuint16m1_t b, size_t vl) +{ + return __riscv_vqwbdota_vv_u16m8_u16m1_u64m1 (acc, a, b, 0, vl); +} + +/* { dg-final { scan-assembler-times {vqwbdotau\.vv} 2 } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/base/zvbdota-intrinsic.c b/gcc/testsuite/gcc.target/riscv/rvv/base/zvbdota-intrinsic.c new file mode 100644 index 000000000000..bb36fc5b0b7d --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/base/zvbdota-intrinsic.c @@ -0,0 +1,135 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv_zvqwbdota8i_zvqwbdota16i_zvfwbdota16bf_zvfqwbdota8f_zvfbdota32f_zvfbfmin_zvl4096b -mabi=lp64d -O2" } */ + +#include "riscv_vector.h" + +vuint32m8_t +test_vqwbdota_uu_8 (vuint32m8_t vd, vuint8m8_t vs2, + vuint8m1_t vs1, size_t vl) +{ + return __riscv_vqwbdota_vv_u8m8_u8m1_u32m8 (vd, vs2, vs1, 8, vl); +} + +vint32m8_t +test_vqwbdota_us_8 (vint32m8_t vd, vuint8m8_t vs2, + vint8m1_t vs1, size_t vl) +{ + return __riscv_vqwbdota_vv_u8m8_i8m1_i32m8 (vd, vs2, vs1, 8, vl); +} + +vint32m8_t +test_vqwbdota_su_8 (vint32m8_t vd, vint8m8_t vs2, + vuint8m1_t vs1, size_t vl) +{ + return __riscv_vqwbdota_vv_i8m8_u8m1_i32m8 (vd, vs2, vs1, 8, vl); +} + +vint32m8_t +test_vqwbdota_ss_8 (vint32m8_t vd, vint8m8_t vs2, + vint8m1_t vs1, size_t vl) +{ + return __riscv_vqwbdota_vv_i8m8_i8m1_i32m8 (vd, vs2, vs1, 8, vl); +} + +vuint64m8_t +test_vqwbdota_uu_16 (vuint64m8_t vd, vuint16m8_t vs2, + vuint16m1_t vs1, size_t vl) +{ + return __riscv_vqwbdota_vv_u16m8_u16m1_u64m8 (vd, vs2, vs1, 16, vl); +} + +vint64m8_t +test_vqwbdota_us_16 (vint64m8_t vd, vuint16m8_t vs2, + vint16m1_t vs1, size_t vl) +{ + return __riscv_vqwbdota_vv_u16m8_i16m1_i64m8 (vd, vs2, vs1, 16, vl); +} + +vint64m8_t +test_vqwbdota_su_16 (vint64m8_t vd, vint16m8_t vs2, + vuint16m1_t vs1, size_t vl) +{ + return __riscv_vqwbdota_vv_i16m8_u16m1_i64m8 (vd, vs2, vs1, 16, vl); +} + +vint64m8_t +test_vqwbdota_ss_16 (vint64m8_t vd, vint16m8_t vs2, + vint16m1_t vs1, size_t vl) +{ + return __riscv_vqwbdota_vv_i16m8_i16m1_i64m8 (vd, vs2, vs1, 16, vl); +} + +vfloat32m8_t +test_vfqwbdota_e4m3_e4m3 (vfloat32m8_t vd, vfloat8e4m3m8_t vs2, + vfloat8e4m3m1_t vs1, size_t vl) +{ + return __riscv_vfqwbdota_vv_f8e4m3m8_f8e4m3m1_f32m8 (vd, vs2, vs1, 24, vl); +} + +vfloat32m8_t +test_vfqwbdota_e4m3_e5m2 (vfloat32m8_t vd, vfloat8e4m3m8_t vs2, + vfloat8e5m2m1_t vs1, size_t vl) +{ + return __riscv_vfqwbdota_vv_f8e4m3m8_f8e5m2m1_f32m8 (vd, vs2, vs1, 24, vl); +} + +vfloat32m8_t +test_vfqwbdota_e5m2_e4m3 (vfloat32m8_t vd, vfloat8e5m2m8_t vs2, + vfloat8e4m3m1_t vs1, size_t vl) +{ + return __riscv_vfqwbdota_vv_f8e5m2m8_f8e4m3m1_f32m8 (vd, vs2, vs1, 32, vl); +} + +vfloat32m8_t +test_vfqwbdota_e5m2_e5m2 (vfloat32m8_t vd, vfloat8e5m2m8_t vs2, + vfloat8e5m2m1_t vs1, size_t vl) +{ + return __riscv_vfqwbdota_vv_f8e5m2m8_f8e5m2m1_f32m8 (vd, vs2, vs1, 32, vl); +} + +vfloat32m8_t +test_vfwbdota_bf16 (vfloat32m8_t vd, vbfloat16m8_t vs2, + vbfloat16m1_t vs1, size_t vl) +{ + return __riscv_vfwbdota_vv_bf16m8_bf16m1_f32m8 (vd, vs2, vs1, 40, vl); +} + +vfloat32m8_t +test_vfbdota (vfloat32m8_t vd, vfloat32m8_t vs2, + vfloat32m1_t vs1, size_t vl) +{ + return __riscv_vfbdota_vv_f32m8 (vd, vs2, vs1, 48, vl); +} + +vfloat32m8_t +test_vfbdota_rm (vfloat32m8_t vd, vfloat32m8_t vs2, + vfloat32m1_t vs1, size_t vl) +{ + return __riscv_vfbdota_vv_f32m8_rm (vd, vs2, vs1, 56, + __RISCV_FRM_RDN, vl); +} + +/* { dg-final { scan-assembler-times {vqwbdotau\.vv} 4 } } */ +/* { dg-final { scan-assembler-times {vqwbdotas\.vv} 4 } } */ +/* { dg-final { scan-assembler-times {vfqwbdota\.vv} 2 } } */ +/* { dg-final { scan-assembler-times {vfqwbdota\.alt\.vv} 2 } } */ +/* { dg-final { scan-assembler-times {vfwbdota\.vv} 1 } } */ +/* { dg-final { scan-assembler-times {vfbdota\.vv} 2 } } */ + +/* { dg-final { scan-assembler-times {vqwbdotau\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+,\s*8} 2 } } */ +/* { dg-final { scan-assembler-times {vqwbdotas\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+,\s*8} 2 } } */ +/* { dg-final { scan-assembler-times {vqwbdotau\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+,\s*16} 2 } } */ +/* { dg-final { scan-assembler-times {vqwbdotas\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+,\s*16} 2 } } */ +/* { dg-final { scan-assembler-times {vfqwbdota\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+,\s*24} 2 } } */ +/* { dg-final { scan-assembler-times {vfqwbdota\.alt\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+,\s*32} 2 } } */ +/* { dg-final { scan-assembler-times {vfwbdota\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+,\s*40} 1 } } */ +/* { dg-final { scan-assembler-times {vfbdota\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+,\s*48} 1 } } */ +/* { dg-final { scan-assembler-times {vfbdota\.vv\s+v[0-9]+,\s*v[0-9]+,\s*v[0-9]+,\s*56} 1 } } */ + +/* { dg-final { scan-assembler-times {vsetvli\s+zero,\s*[a-z0-9]+,\s*e8,\s*m1,\s*ta,\s*ma} 4 } } */ +/* { dg-final { scan-assembler-times {vsetvli\s+zero,\s*[a-z0-9]+,\s*e8alt,\s*m1,\s*ta,\s*ma} 4 } } */ +/* { dg-final { scan-assembler-times {vsetvli\s+zero,\s*[a-z0-9]+,\s*e16,\s*m1,\s*ta,\s*ma} 2 } } */ +/* { dg-final { scan-assembler-times {vsetvli\s+zero,\s*[a-z0-9]+,\s*e16alt,\s*m1,\s*ta,\s*ma} 3 } } */ +/* { dg-final { scan-assembler-times {vsetvli\s+zero,\s*[a-z0-9]+,\s*e32,\s*m1,\s*ta,\s*ma} 2 } } */ +/* { dg-final { scan-assembler-times {fsrmi\s+[0-4]} 1 } } */ +/* { dg-final { scan-assembler-times {fsrm\s+[a-z0-9]+} 1 } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/base/zvbdota-no-overlap.c b/gcc/testsuite/gcc.target/riscv/rvv/base/zvbdota-no-overlap.c new file mode 100644 index 000000000000..bd1669d39113 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/base/zvbdota-no-overlap.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv_zvfbdota32f_zvl512b -mabi=lp64d -O2" } */ + +#include "riscv_vector.h" + +/* Equal accumulator and source values still need disjoint registers. */ +vfloat32m1_t +test_same_vs1 (vfloat32m1_t acc, vfloat32m8_t a, size_t vl) +{ + return __riscv_vfbdota_vv_f32m1 (acc, a, acc, 0, vl); +} + +vfloat32m8_t +test_same_vs2 (vbool4_t mask, vfloat32m8_t acc, vfloat32m1_t b, size_t vl) +{ + return __riscv_vfbdota_vv_f32m8_m (mask, acc, acc, b, 0, vl); +} + +/* { dg-final { scan-assembler-times {vfbdota\.vv} 2 } } */ +/* { dg-final { scan-assembler-not {vfbdota\.vv\s+(v[0-9]+),\s*\1,} } } */ +/* { dg-final { scan-assembler-not {vfbdota\.vv\s+(v[0-9]+),\s*v[0-9]+,\s*\1,} } } */ +/* { dg-final { scan-assembler-not {vfbdota\.vv\s+v0,.*v0\.t} } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/base/zvbdota-no-rm-fail.c b/gcc/testsuite/gcc.target/riscv/rvv/base/zvbdota-no-rm-fail.c new file mode 100644 index 000000000000..03b1f5fc05e6 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/base/zvbdota-no-rm-fail.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv_zvfwbdota16bf_zvfqwbdota8f_zvfbfmin_zvl512b -mabi=lp64d -O2 -Werror=implicit-function-declaration" } */ + +#include "riscv_vector.h" + +void +test_vfwbdota_rm (vfloat32m8_t vd, vbfloat16m8_t vs2, + vbfloat16m1_t vs1, size_t vl) +{ + (void) __riscv_vfwbdota_vv_bf16m8_bf16m1_f32m8_rm (vd, vs2, vs1, 0, __RISCV_FRM_RNE, vl); /* { dg-error "implicit declaration of function" } */ +} + +void +test_vfqwbdota_rm (vfloat32m8_t vd, vfloat8e4m3m8_t vs2, + vfloat8e4m3m1_t vs1, size_t vl) +{ + (void) __riscv_vfqwbdota_vv_f8e4m3m8_f8e4m3m1_f32m8_rm (vd, vs2, vs1, 8, __RISCV_FRM_RNE, vl); /* { dg-error "implicit declaration of function" } */ +} + +void +test_vfqwbdota_e5m2_rm (vfloat32m8_t vd, vfloat8e5m2m8_t vs2, + vfloat8e4m3m1_t vs1, size_t vl) +{ + (void) __riscv_vfqwbdota_vv_f8e5m2m8_f8e4m3m1_f32m8_rm (vd, vs2, vs1, 16, __RISCV_FRM_RNE, vl); /* { dg-error "implicit declaration of function" } */ +} diff --git a/gcc/testsuite/gcc.target/riscv/rvv/base/zvbdota-require-extension.c b/gcc/testsuite/gcc.target/riscv/rvv/base/zvbdota-require-extension.c new file mode 100644 index 000000000000..cee7007fa05d --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/base/zvbdota-require-extension.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d -O2" } */ + +#include "riscv_vector.h" + +vfloat32m1_t +test_f32 (vfloat32m1_t acc, vfloat32m8_t a, vfloat32m1_t b, size_t vl) +{ + return __riscv_vfbdota_vv_f32m1 (acc, a, b, 0, vl); /* { dg-error {requires.*zvfbdota32f} } */ +}
