https://gcc.gnu.org/g:7e81d9c9f2f5cd7e75f333370939f0cdd1e7ee77
commit r17-6414-g7e81d9c9f2f5cd7e75f333370939f0cdd1e7ee77 Author: Jiawei <[email protected]> Date: Wed Oct 14 16:48:47 2026 +0800 RISC-V: Add machine patterns for Zvdota and Zvbdota instructions Add reduction-style dot-product patterns with static altfmt requirements and earlyclobber constraints. Keep integer extension guards in iterators. Use dot-product types for shared VL/policy attributes and scheduling. Exclude these types from AVL propagation because VL counts reduction terms rather than accumulator elements. gcc/ChangeLog: * config/riscv/generic-vector-ooo.md (vec_imul, vec_fmul): Handle dot-product types. * config/riscv/andes-23-series.md (andes_23_unknown): Likewise. * config/riscv/andes-25-series.md (andes_25_vector_unknown): Likewise. * config/riscv/andes-45-series.md (andes_45_vector_unknown): Likewise. * config/riscv/arcv-rhx100.md (arcv_rhx100_unknown): Likewise. * config/riscv/arcv-rmx100.md (arcv_rmx100_unknown): Likewise. * config/riscv/mips-i8500.md (mips_i8500_unknown): Likewise. * config/riscv/mips-p8700.md (mips_p8700_unknown): Likewise. * config/riscv/sifive-7.md (sifive_7_vec_unknown): Likewise. * config/riscv/sifive-p400.md (sifive_p400_unknown): Likewise. * config/riscv/sifive-p600.md (sifive_p600_unknown): Likewise. * config/riscv/spacemit-x60.md (spacemit_x60_dummy): Likewise. * config/riscv/tt-ascalon-d8.md (tt_ascalon_d8_vec_unknown): Likewise. * config/riscv/xiangshan.md (xiangshan_alu_unknown): Likewise. * config/riscv/xt-c908.md (xt_c908_dummy): Likewise. * config/riscv/predicates.md (zvbdota_ci_operand): New predicate. * config/riscv/riscv-avlprop.cc (avl_can_be_propagated_p): Exclude dot-product types. * config/riscv/riscv-protos.h (altfmt_type): Extend comment. * config/riscv/riscv.md (type, fp_vector_disabled): Add dot-product types. Include vector-dot.md. * config/riscv/vector.md (has_vtype_op, has_vl_op, ratio, merge_op_idx, mode_idx, vl_op_idx, ta, ma, avl_type_idx): Handle dot-product types. * config/riscv/vector-dot.md: New file. * config/riscv/vector-iterators.md: Add dot-product UNSPECs, mode mappings and extension-specific iterators. (V_EXT_LMUL1): Add BF16 modes. Diff: --- gcc/config/riscv/andes-23-series.md | 3 +- gcc/config/riscv/andes-25-series.md | 3 +- gcc/config/riscv/andes-45-series.md | 3 +- gcc/config/riscv/arcv-rhx100.md | 3 +- gcc/config/riscv/arcv-rmx100.md | 3 +- gcc/config/riscv/generic-vector-ooo.md | 5 +- gcc/config/riscv/mips-i8500.md | 3 +- gcc/config/riscv/mips-p8700.md | 3 +- gcc/config/riscv/predicates.md | 5 + gcc/config/riscv/riscv-avlprop.cc | 12 +- gcc/config/riscv/riscv-protos.h | 8 +- gcc/config/riscv/riscv.md | 9 +- gcc/config/riscv/sifive-7.md | 3 +- gcc/config/riscv/sifive-p400.md | 25 +++- gcc/config/riscv/sifive-p600.md | 25 +++- gcc/config/riscv/spacemit-x60.md | 3 +- gcc/config/riscv/tt-ascalon-d8.md | 3 +- gcc/config/riscv/vector-dot.md | 202 +++++++++++++++++++++++++++++++++ gcc/config/riscv/vector-iterators.md | 191 +++++++++++++++++++++++++++++++ gcc/config/riscv/vector.md | 39 +++++-- gcc/config/riscv/xiangshan.md | 26 ++++- gcc/config/riscv/xt-c908.md | 3 +- 22 files changed, 546 insertions(+), 34 deletions(-) diff --git a/gcc/config/riscv/andes-23-series.md b/gcc/config/riscv/andes-23-series.md index f0f0a44f7139..70b4da3435c7 100644 --- a/gcc/config/riscv/andes-23-series.md +++ b/gcc/config/riscv/andes-23-series.md @@ -186,5 +186,6 @@ vfslide1up,vfncvtftof,vsetvl,viwmuladd,vfredu,vfwredu, vlsegde,vmiota,vstr,vgather,vssegts,vldux,vlsegds,vimul, vste,vsetvl_pre,vimuladd,vcompress,vssegtux,wrfrm,rdfrm, - vired,xt_vgmulxor,xt_vcrcfold,xt_vile,xt_vilo")) + vired,xt_vgmulxor,xt_vcrcfold,xt_vile,xt_vilo, + vidota,vfdota,vibdota,vfbdota")) "andes_23_dummies") diff --git a/gcc/config/riscv/andes-25-series.md b/gcc/config/riscv/andes-25-series.md index c11fe16d6e49..c9e9c5e7c552 100644 --- a/gcc/config/riscv/andes-25-series.md +++ b/gcc/config/riscv/andes-25-series.md @@ -319,5 +319,6 @@ vsm3me,vbrev,vctz,vgmul,vsha2ms,vaesz,vrev8, vaeskf2,vsha2cl,vwsll,vaesdf,vaesem,vfwmaccbf16, sf_vqmacc,sf_vc,sf_vc_se,sf_vfnrclip, - xt_vgmulxor,xt_vcrcfold,xt_vile,xt_vilo")) + xt_vgmulxor,xt_vcrcfold,xt_vile,xt_vilo, + vidota,vfdota,vibdota,vfbdota")) "andes_25_vector_dummies") diff --git a/gcc/config/riscv/andes-45-series.md b/gcc/config/riscv/andes-45-series.md index 4e3cf79dbe80..c4d02b8c5392 100644 --- a/gcc/config/riscv/andes-45-series.md +++ b/gcc/config/riscv/andes-45-series.md @@ -376,5 +376,6 @@ vsm3me,vbrev,vctz,vgmul,vsha2ms,vaesz,vrev8, vaeskf2,vsha2cl,vwsll,vaesdf,vaesem,vfwmaccbf16, sf_vqmacc,sf_vc,sf_vc_se,sf_vfnrclip,vlsegde, - xt_vgmulxor,xt_vcrcfold,xt_vile,xt_vilo")) + xt_vgmulxor,xt_vcrcfold,xt_vile,xt_vilo, + vidota,vfdota,vibdota,vfbdota")) "andes_45_vector_dummies") diff --git a/gcc/config/riscv/arcv-rhx100.md b/gcc/config/riscv/arcv-rhx100.md index 72f0147ea364..a0340ceb0df1 100644 --- a/gcc/config/riscv/arcv-rhx100.md +++ b/gcc/config/riscv/arcv-rhx100.md @@ -121,7 +121,8 @@ vimerge,vror,rdvlenb,vfwcvtitof,vaesdf,viwmuladd,vrev8, vsm4r,vsalu,vfminmax,vicalu,vslideup,vldox,vstm, vfwcvtbf16,vfmovfv,vfslide1up,vimovxv,sf_vc,sf_vqmacc, - sf_vc_se,xt_vgmulxor,xt_vcrcfold,xt_vile,xt_vilo")) + sf_vc_se,xt_vgmulxor,xt_vcrcfold,xt_vile,xt_vilo, + vidota,vfdota,vibdota,vfbdota")) "(arcv_rhx100_issueA_fuse0 + arcv_rhx100_issueA_fuse1) | (arcv_rhx100_issueB_fuse0 + arcv_rhx100_issueB_fuse1)") ;; Bypasses diff --git a/gcc/config/riscv/arcv-rmx100.md b/gcc/config/riscv/arcv-rmx100.md index e786cbb3ee43..e2152f38eb95 100644 --- a/gcc/config/riscv/arcv-rmx100.md +++ b/gcc/config/riscv/arcv-rmx100.md @@ -109,7 +109,8 @@ vimerge,vror,rdvlenb,vfwcvtitof,vaesdf,viwmuladd,vrev8, vsm4r,vsalu,vfminmax,vicalu,vslideup,vldox,vstm, vfwcvtbf16,vfmovfv,vfslide1up,vimovxv,sf_vc,sf_vqmacc, - sf_vc_se,xt_vgmulxor,xt_vcrcfold,xt_vile,xt_vilo")) + sf_vc_se,xt_vgmulxor,xt_vcrcfold,xt_vile,xt_vilo, + vidota,vfdota,vibdota,vfbdota")) "arcv_rmx100_ALU") diff --git a/gcc/config/riscv/generic-vector-ooo.md b/gcc/config/riscv/generic-vector-ooo.md index d6beb1be244c..bd62e7cbaa2c 100644 --- a/gcc/config/riscv/generic-vector-ooo.md +++ b/gcc/config/riscv/generic-vector-ooo.md @@ -71,7 +71,7 @@ (define_insn_reservation "vec_imul" 4 (and (eq_attr "tune" "generic_ooo,generic") (eq_attr "type" "vimul,viwmul,vimuladd,viwmuladd,vsmul,vclmul,vclmulh,\ - vghsh,vgmul,xt_vgmulxor,xt_vcrcfold")) + vghsh,vgmul,xt_vgmulxor,xt_vcrcfold,vidota,vibdota")) "vxu_ooo_issue,vxu_ooo_alu") ;; Vector float addition. @@ -83,7 +83,8 @@ ;; Vector float multiplication and FMA. (define_insn_reservation "vec_fmul" 6 (and (eq_attr "tune" "generic_ooo,generic") - (eq_attr "type" "vfmul,vfwmul,vfmuladd,vfwmuladd,vfwmaccbf16,sf_vqmacc,sf_vfnrclip")) + (eq_attr "type" "vfmul,vfwmul,vfmuladd,vfwmuladd,vfwmaccbf16,\ + vfdota,vfbdota,sf_vqmacc,sf_vfnrclip")) "vxu_ooo_issue,vxu_ooo_alu") ;; Vector crypto, assumed to be a generic operation for now. diff --git a/gcc/config/riscv/mips-i8500.md b/gcc/config/riscv/mips-i8500.md index 21879d598c13..dc74ddad7f2a 100644 --- a/gcc/config/riscv/mips-i8500.md +++ b/gcc/config/riscv/mips-i8500.md @@ -160,5 +160,6 @@ vfsqrt, vsshift, vfmovfv, vcpop, vshift, vsm4r, vimovvx, vialu, vmiota, vclmulh, vimul, vfmul, vsetvl, vaesdf, vfncvtitof, vfwcvtitof, vmov, vssegte, vaesef, vicalu, vaesz, vlsegds, vaalu, vfminmax, vlde, - xt_vile, xt_vilo, xt_vcrcfold, xt_vgmulxor")) + xt_vile, xt_vilo, xt_vcrcfold, xt_vgmulxor, + vidota, vfdota, vibdota, vfbdota")) "mips_i8500_control_alu0") diff --git a/gcc/config/riscv/mips-p8700.md b/gcc/config/riscv/mips-p8700.md index bccdb6c6a0de..e1b5f53ee127 100644 --- a/gcc/config/riscv/mips-p8700.md +++ b/gcc/config/riscv/mips-p8700.md @@ -163,5 +163,6 @@ vgather,vcompress,vmov,vector,vandn,vbrev,vbrev8,vrev8,vclz,vctz,vcpop,vrol,vror,vwsll, vclmul,vclmulh,vghsh,vgmul,vaesef,vaesem,vaesdf,vaesdm,vaeskf1,vaeskf2,vaesz, vsha2ms,vsha2ch,vsha2cl,vsm4k,vsm4r,vsm3me,vsm3c,vfncvtbf16,vfwcvtbf16,vfwmaccbf16, - sf_vc,sf_vc_se,ghost,xt_vgmulxor,xt_vcrcfold,xt_vile,xt_vilo")) + sf_vc,sf_vc_se,ghost,xt_vgmulxor,xt_vcrcfold,xt_vile,xt_vilo, + vidota,vfdota,vibdota,vfbdota")) "mips_p8700_dummies") diff --git a/gcc/config/riscv/predicates.md b/gcc/config/riscv/predicates.md index 9ffe2fc2d528..551d23432f41 100644 --- a/gcc/config/riscv/predicates.md +++ b/gcc/config/riscv/predicates.md @@ -83,6 +83,11 @@ (and (match_code "const_int") (match_test "IN_RANGE (INTVAL (op), 0, 10)"))) +(define_predicate "zvbdota_ci_operand" + (and (match_code "const_int") + (match_test "IN_RANGE (INTVAL (op), 0, 56) + && INTVAL (op) % 8 == 0"))) + (define_predicate "csr_operand" (ior (match_operand 0 "const_csr_operand") (match_operand 0 "register_operand"))) diff --git a/gcc/config/riscv/riscv-avlprop.cc b/gcc/config/riscv/riscv-avlprop.cc index 5bd70e6b030e..676412c2ee0e 100644 --- a/gcc/config/riscv/riscv-avlprop.cc +++ b/gcc/config/riscv/riscv-avlprop.cc @@ -146,14 +146,22 @@ avl_can_be_propagated_p (rtx_insn *rinsn) - It read pairs of adjacent elements of source vectors. It does not read past AVL when AVL is odd, but needs an even AVL to perform correctly even if the consumer only nees an odd number of - elements. */ + elements. + Dot products: + - VL counts reduction terms rather than live accumulator elements, + so propagating it into an accumulator producer can discard values + that the dot product still needs. */ return get_attr_type (rinsn) != TYPE_VGATHER && get_attr_type (rinsn) != TYPE_VSLIDEDOWN && get_attr_type (rinsn) != TYPE_VISLIDE1DOWN && get_attr_type (rinsn) != TYPE_VFSLIDE1DOWN && get_attr_type (rinsn) != TYPE_VCOMPRESS && get_attr_type (rinsn) != TYPE_XT_VCRCFOLD - && get_attr_type (rinsn) != TYPE_XT_VILO; + && get_attr_type (rinsn) != TYPE_XT_VILO + && get_attr_type (rinsn) != TYPE_VIDOTA + && get_attr_type (rinsn) != TYPE_VFDOTA + && get_attr_type (rinsn) != TYPE_VIBDOTA + && get_attr_type (rinsn) != TYPE_VFBDOTA; } static bool diff --git a/gcc/config/riscv/riscv-protos.h b/gcc/config/riscv/riscv-protos.h index a89e93cbe30f..1fe0c4483d02 100644 --- a/gcc/config/riscv/riscv-protos.h +++ b/gcc/config/riscv/riscv-protos.h @@ -666,10 +666,10 @@ enum mask_policy }; /* Values for the VTYPE altfmt field. Instructions that do not care about - altfmt leave the "altfmt" insn attribute at its default (INVALID_ATTRIBUTE); - FP8 instructions select between standard (ALTFMT_NONE, E4M3) and the - alternate format (ALTFMT_ALT, E5M2) by setting the attribute via an - operand. */ + altfmt leave the "altfmt" insn attribute at its default (INVALID_ATTRIBUTE). + FP8 instructions select between standard (ALTFMT_NONE, E4M3) and alternate + (ALTFMT_ALT, E5M2) formats. Dot-product instructions use distinct UNSPECs + to select the signedness or FP8 format of vs1 statically. */ enum altfmt_type { ALTFMT_NONE = 0, diff --git a/gcc/config/riscv/riscv.md b/gcc/config/riscv/riscv.md index f9128bbdc383..ccd692d28745 100644 --- a/gcc/config/riscv/riscv.md +++ b/gcc/config/riscv/riscv.md @@ -491,6 +491,11 @@ ;; vfncvtbf16 vector narrowing single floating-point to brain floating-point instruction ;; vfwcvtbf16 vector widening brain floating-point to single floating-point instruction ;; vfwmaccbf16 vector BF16 widening multiply-accumulate +;; 19. Vector dot-product instructions +;; vidota vector integer dot-product accumulate instructions +;; vfdota vector floating-point dot-product accumulate instructions +;; vibdota vector integer batched dot-product accumulate instructions +;; vfbdota vector floating-point batched dot-product accumulation ;; SiFive custom extension instructions ;; sf_vqmacc vector matrix integer multiply-add instructions ;; sf_vfnrclip vector fp32 to int8 ranged clip instructions @@ -523,6 +528,7 @@ vgather,vcompress,vmov,vector,vandn,vbrev,vbrev8,vrev8,vclz,vctz,vcpop,vrol,vror,vwsll, vclmul,vclmulh,vghsh,vgmul,vaesef,vaesem,vaesdf,vaesdm,vaeskf1,vaeskf2,vaesz, vsha2ms,vsha2ch,vsha2cl,vsm4k,vsm4r,vsm3me,vsm3c,vfncvtbf16,vfwcvtbf16,vfwmaccbf16, + vidota,vfdota,vibdota,vfbdota, sf_vc,sf_vc_se,xt_vgmulxor,xt_vcrcfold,xt_vile,xt_vilo" (cond [(eq_attr "got" "load") (const_string "load") @@ -559,7 +565,7 @@ (define_attr "fp_vector_disabled" "no,yes" (cond [ (and (eq_attr "type" "vfmov,vfalu,vfmul,vfdiv, - vfwalu,vfwmul,vfmuladd,vfwmuladd, + vfwalu,vfwmul,vfmuladd,vfwmuladd,vfdota,vfbdota, vfsqrt,vfrecp,vfminmax,vfsgnj,vfcmp, vfclass,vfmerge, vfncvtitof,vfwcvtftoi,vfcvtftoi,vfcvtitof, @@ -5582,6 +5588,7 @@ (include "vector.md") (include "vector-crypto.md") (include "vector-bfloat16.md") +(include "vector-dot.md") (include "zicond.md") (include "mips-insn.md") (include "sfb.md") diff --git a/gcc/config/riscv/sifive-7.md b/gcc/config/riscv/sifive-7.md index 2ba25a62b4a7..94dcb9355b8d 100644 --- a/gcc/config/riscv/sifive-7.md +++ b/gcc/config/riscv/sifive-7.md @@ -302,5 +302,6 @@ vaesef,vaesem,vaesdf,vaesdm,vaeskf1,vaeskf2, vaesz,vsha2ms,vsha2ch,vsha2cl, vsm4k,vsm4r,vsm3me,vsm3c,sf_vc,sf_vc_se, - xt_vgmulxor,xt_vcrcfold,xt_vile,xt_vilo")) + xt_vgmulxor,xt_vcrcfold,xt_vile,xt_vilo, + vidota,vfdota,vibdota,vfbdota")) "sifive_7_vcq,sifive_7_va*6") diff --git a/gcc/config/riscv/sifive-p400.md b/gcc/config/riscv/sifive-p400.md index a859a81f635a..9a19f0a4b314 100644 --- a/gcc/config/riscv/sifive-p400.md +++ b/gcc/config/riscv/sifive-p400.md @@ -192,7 +192,30 @@ ;; they are just dummies like this one. (define_insn_reservation "sifive_p400_unknown" 1 (and (eq_attr "tune" "sifive_p400") - (eq_attr "type" "ghost,vfrecp,vclmul,vldm,vmffs,vclmulh,vlsegde,vfcvtitof,vsm4k,vfcvtftoi,vfdiv,vsm3c,vsm4r,viwmuladd,vfwredu,vcpop,vfwmuladd,vstux,vsshift,vfwcvtftof,vfncvtftof,vfwmaccbf16,vext,vssegte,rdvl,vaeskf1,vfslide1up,vmov,vimovvx,vaesef,vfsqrt,viminmax,vfwcvtftoi,vssegtox,vfclass,viwmul,vector,vgmul,vsm3me,vfcmp,vstm,vfredo,vfwmul,vaeskf2,vstox,vfncvtbf16,vislide1up,vgather,vldox,viwred,vctz,vghsh,vsts,vslidedown,vfmerge,vicmp,vsmul,vlsegdff,vfalu,vfmov,vislide1down,vfminmax,vcompress,vldr,vldff,vlsegdux,vimuladd,vsalu,vidiv,sf_vqmacc,vfslide1down,vaesem,vimerge,vfncvtftoi,vfwcvtitof,vicalu,vaesz,sf_vc_se,vsha2cl,vmsfs,vldux,vmidx,vslideup,vired,vlde,vfwredo,vfmovfv,vbrev,vfncvtitof,rdfrm,vsetvl,vssegts,vimul,vialu,vbrev8,vfwalu,rdvlenb,sf_vfnrclip,vclz,vnclip,sf_vc,vimov,vste,vfmuladd,vfmovvf,vwsll,vsetvl_pre,vlds,vlsegds,vmiota,vmalu,wrvxrm,wrfrm,viwalu,vaesdm,vssegtux,vaesdf,vimovxv,vror,vnshift,vstr,vaalu,vsha2ms,crypto,vfwcvtbf16,vlsegdox,vrol,vandn,vfsgnj,vmpo p,vfredu,vsha2ch,vshift,vrev8,vfmul,xt_vgmulxor,xt_vcrcfold,xt_vile,xt_vilo")) + (eq_attr "type" "ghost,vfrecp,vclmul,vldm,vmffs,vclmulh,vlsegde, + vfcvtitof,vsm4k,vfcvtftoi,vfdiv,vsm3c,vsm4r, + viwmuladd,vfwredu,vcpop,vfwmuladd,vstux,vsshift, + vfwcvtftof,vfncvtftof,vfwmaccbf16,vext,vssegte, + rdvl,vaeskf1,vfslide1up,vmov,vimovvx,vaesef, + vfsqrt,viminmax,vfwcvtftoi,vssegtox,vfclass, + viwmul,vector,vgmul,vsm3me,vfcmp,vstm,vfredo, + vfwmul,vaeskf2,vstox,vfncvtbf16,vislide1up, + vgather,vldox,viwred,vctz,vghsh,vsts,vslidedown, + vfmerge,vicmp,vsmul,vlsegdff,vfalu,vfmov, + vislide1down,vfminmax,vcompress,vldr,vldff, + vlsegdux,vimuladd,vsalu,vidiv,sf_vqmacc, + vfslide1down,vaesem,vimerge,vfncvtftoi,vfwcvtitof, + vicalu,vaesz,sf_vc_se,vsha2cl,vmsfs,vldux,vmidx, + vslideup,vired,vlde,vfwredo,vfmovfv,vbrev, + vfncvtitof,rdfrm,vsetvl,vssegts,vimul,vialu, + vbrev8,vfwalu,rdvlenb,sf_vfnrclip,vclz,vnclip, + sf_vc,vimov,vste,vfmuladd,vfmovvf,vwsll, + vsetvl_pre,vlds,vlsegds,vmiota,vmalu,wrvxrm,wrfrm, + viwalu,vaesdm,vssegtux,vaesdf,vimovxv,vror, + vnshift,vstr,vaalu,vsha2ms,crypto,vfwcvtbf16, + vlsegdox,vrol,vandn,vfsgnj,vmpop,vfredu,vsha2ch, + vshift,vrev8,vfmul,vidota,vfdota,vibdota,vfbdota, + xt_vgmulxor,xt_vcrcfold,xt_vile,xt_vilo")) "p400_int_pipe+sifive_p400_ialu") diff --git a/gcc/config/riscv/sifive-p600.md b/gcc/config/riscv/sifive-p600.md index c4d9c577436d..e845b4e75bfc 100644 --- a/gcc/config/riscv/sifive-p600.md +++ b/gcc/config/riscv/sifive-p600.md @@ -195,5 +195,28 @@ ;; they are just dummies like this one. (define_insn_reservation "sifive_p600_unknown" 1 (and (eq_attr "tune" "sifive_p600") - (eq_attr "type" "vicmp,vssegte,vbrev8,vfwalu,vimov,vmpop,vaesdf,vislide1up,vror,vsha2cl,vrol,vslideup,vimuladd,vclmul,vaesef,vext,vlsegdff,vfmuladd,vfclass,vmsfs,vfcmp,vsmul,vsm3me,vmalu,vshift,viwmuladd,vfslide1up,vlsegde,vsm4k,wrvxrm,vislide1down,vsm3c,vfwmuladd,vaesdm,vclmulh,vfwcvtftof,vfwredu,vfredo,sf_vfnrclip,vaesz,vwsll,vmiota,vctz,vsetvl_pre,vstm,vidiv,vssegtux,vfwmul,vcompress,vste,vired,vlsegds,vaesem,vfminmax,ghost,vandn,crypto,vfmul,vialu,vfmovvf,rdfrm,vldff,vfmerge,vsshift,vnclip,sf_vqmacc,vnshift,vfdiv,vfslide1down,vfncvtitof,vfsqrt,vimovxv,vstr,vfwcvtbf16,vfwcvtitof,vbrev,vssegtox,vssegts,vcpop,vmffs,viwmul,vldr,vmidx,rdvlenb,vfalu,vslidedown,vlde,vfsgnj,vfmov,viwalu,vsha2ch,vfncvtbf16,vfcvtitof,rdvl,vsetvl,vsha2ms,vector,vstux,vimerge,vclz,sf_vc,vfcvtftoi,viminmax,vsm4r,sf_vc_se,wrfrm,vstox,vfmovfv,vfncvtftoi,vimul,vsalu,vmov,vgmul,vgather,vldux,vlsegdox,vfncvtftof,vimovvx,vghsh,vldm,vldox,vfwcvtftoi,vlds,vfrecp,vaeskf2,vsts,vfredu,vicalu,vaalu,vfwmaccbf16,vr ev8,vfwredo,vlsegdux,viwred,vaeskf1,xt_vgmulxor,xt_vcrcfold,xt_vile,xt_vilo")) + (eq_attr "type" "vicmp,vssegte,vbrev8,vfwalu,vimov,vmpop,vaesdf, + vislide1up,vror,vsha2cl,vrol,vslideup,vimuladd, + vclmul,vaesef,vext,vlsegdff,vfmuladd,vfclass, + vmsfs,vfcmp,vsmul,vsm3me,vmalu,vshift,viwmuladd, + vfslide1up,vlsegde,vsm4k,wrvxrm,vislide1down, + vsm3c,vfwmuladd,vaesdm,vclmulh,vfwcvtftof,vfwredu, + vfredo,sf_vfnrclip,vaesz,vwsll,vmiota,vctz, + vsetvl_pre,vstm,vidiv,vssegtux,vfwmul,vcompress, + vste,vired,vlsegds,vaesem,vfminmax,ghost,vandn, + crypto,vfmul,vialu,vfmovvf,rdfrm,vldff,vfmerge, + vsshift,vnclip,sf_vqmacc,vnshift,vfdiv, + vfslide1down,vfncvtitof,vfsqrt,vimovxv,vstr, + vfwcvtbf16,vfwcvtitof,vbrev,vssegtox,vssegts, + vcpop,vmffs,viwmul,vldr,vmidx,rdvlenb,vfalu, + vslidedown,vlde,vfsgnj,vfmov,viwalu,vsha2ch, + vfncvtbf16,vfcvtitof,rdvl,vsetvl,vsha2ms,vector, + vstux,vimerge,vclz,sf_vc,vfcvtftoi,viminmax,vsm4r, + sf_vc_se,wrfrm,vstox,vfmovfv,vfncvtftoi,vimul, + vsalu,vmov,vgmul,vgather,vldux,vlsegdox, + vfncvtftof,vimovvx,vghsh,vldm,vldox,vfwcvtftoi, + vlds,vfrecp,vaeskf2,vsts,vfredu,vicalu,vaalu, + vfwmaccbf16,vrev8,vfwredo,vlsegdux,viwred,vaeskf1, + vidota,vfdota,vibdota,vfbdota, + xt_vgmulxor,xt_vcrcfold,xt_vile,xt_vilo")) "int_pipe+sifive_p600_ialu") diff --git a/gcc/config/riscv/spacemit-x60.md b/gcc/config/riscv/spacemit-x60.md index f34d358c8913..e96f6b863c6a 100644 --- a/gcc/config/riscv/spacemit-x60.md +++ b/gcc/config/riscv/spacemit-x60.md @@ -406,5 +406,6 @@ vaesem,vaesdf,ghost,vsm3me,sf_vc_se,vsm3c, vaeskf2,vsha2ms,vector,wrvxrm, vclmul,rdfrm,wrfrm,sf_vc,vsm4k,vsm4r, - xt_vgmulxor,xt_vcrcfold,xt_vile,xt_vilo")) + xt_vgmulxor,xt_vcrcfold,xt_vile,xt_vilo, + vidota,vfdota,vibdota,vfbdota")) "nothing") diff --git a/gcc/config/riscv/tt-ascalon-d8.md b/gcc/config/riscv/tt-ascalon-d8.md index 7bcadb16e4a2..5ea0e46abd51 100644 --- a/gcc/config/riscv/tt-ascalon-d8.md +++ b/gcc/config/riscv/tt-ascalon-d8.md @@ -380,5 +380,6 @@ (and (eq_attr "tune" "tt_ascalon_d8,tt_ascalon_xg") (eq_attr "type" "sf_vc,sf_vc_se,sf_vqmacc,sf_vfnrclip,\ vsm3me,vsm4r,vsm4k,vsm3c,ghost,\ - mfc,mtc,rdfrm,xt_vgmulxor,xt_vcrcfold,xt_vile,xt_vilo")) + mfc,mtc,rdfrm,xt_vgmulxor,xt_vcrcfold,xt_vile,xt_vilo,\ + vidota,vfdota,vibdota,vfbdota")) "tt_ascalon_d8_decode,tt_ascalon_d8_vec") diff --git a/gcc/config/riscv/vector-dot.md b/gcc/config/riscv/vector-dot.md new file mode 100644 index 000000000000..79780b0599c4 --- /dev/null +++ b/gcc/config/riscv/vector-dot.md @@ -0,0 +1,202 @@ +;; Machine description for RISC-V vector dot-product extensions. +;; Copyright (C) 2026 Free Software Foundation, Inc. +;; Contributed by Jiawei Chen ([email protected]), ISCAS. + +;; This file is part of GCC. + +;; GCC is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 3, or (at your option) +;; any later version. + +;; GCC is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GCC; see the file COPYING3. If not see +;; <http://www.gnu.org/licenses/>. + +;; Earlyclobber prevents overlap with either source group or the mask. +;; The accumulator is tied to the result. +;; Distinct UNSPECs select each signedness or FP8 format combination, making +;; the altfmt requirement an instruction property. +;; Like reductions, these operations are opaque: VL counts source terms, +;; not active accumulator elements. Zvdota masks source terms; Zvbdota +;; masks the eight accumulator elements selected by ci. + +;; Zvdota dot-product instructions. The accumulator always has EMUL=1, +;; independently of the source LMUL. + +(define_insn "@pred_<dot_name>_vv_zvdota<mode>" + [(set (match_operand:<V_QUAD_EXT_LMUL1> 0 "register_operand" "=&vr") + (unspec:<V_QUAD_EXT_LMUL1> + [(unspec:<VM> + [(match_operand:<VM> 1 "vector_mask_operand" "vmWc1") + (match_operand 5 "vector_length_operand" "rvl") + (match_operand 6 "const_int_operand" "i") + (match_operand 7 "const_int_operand" "i") + (match_operand 8 "const_int_operand" "i") + (reg:SI VL_REGNUM) + (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE) + (unspec:<V_QUAD_EXT_LMUL1> + [(match_operand:VI_ZVQWDOTA 3 "register_operand" "vr") + (match_operand:VI_ZVQWDOTA 4 "register_operand" "vr") + (match_operand:<V_QUAD_EXT_LMUL1> 2 "register_operand" "0")] + ZVQWDOT) + (match_dup 2)] UNSPEC_REDUC))] + "TARGET_VECTOR" + "<dot_asm>.vv\t%0,%3,%4%p1" + [(set_attr "type" "vidota") + (set_attr "mode" "<MODE>") + (set (attr "altfmt") (symbol_ref "riscv_vector::<dot_altfmt>"))]) + +(define_insn "@pred_vfwdota_vv_zvdota<mode>" + [(set (match_operand:<V_EXT_LMUL1> 0 "register_operand" "=&vr") + (unspec:<V_EXT_LMUL1> + [(unspec:<VM> + [(match_operand:<VM> 1 "vector_mask_operand" "vmWc1") + (match_operand 5 "vector_length_operand" "rvl") + (match_operand 6 "const_int_operand" "i") + (match_operand 7 "const_int_operand" "i") + (match_operand 8 "const_int_operand" "i") + (reg:SI VL_REGNUM) + (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE) + (unspec:<V_EXT_LMUL1> + [(match_operand:VF_ZVFBF16 3 "register_operand" "vr") + (match_operand:VF_ZVFBF16 4 "register_operand" "vr") + (match_operand:<V_EXT_LMUL1> 2 "register_operand" "0")] + UNSPEC_VFWDOTA) + (match_dup 2)] UNSPEC_REDUC))] + "TARGET_ZVFWDOTA16BF && TARGET_VECTOR_ELEN_FP_32" + "vfwdota.vv\t%0,%3,%4%p1" + [(set_attr "type" "vfdota") + (set_attr "mode" "<MODE>") + (set (attr "altfmt") (symbol_ref "riscv_vector::ALTFMT_ALT"))]) + +(define_insn "@pred_<dot_name>_vv_zvdota<mode>" + [(set (match_operand:RVVM1SF 0 "register_operand" "=&vr") + (unspec:RVVM1SF + [(unspec:<VM> + [(match_operand:<VM> 1 "vector_mask_operand" "vmWc1") + (match_operand 5 "vector_length_operand" "rvl") + (match_operand 6 "const_int_operand" "i") + (match_operand 7 "const_int_operand" "i") + (match_operand 8 "const_int_operand" "i") + (reg:SI VL_REGNUM) + (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE) + (unspec:RVVM1SF + [(match_operand:VDOT_QI 3 "register_operand" "vr") + (match_operand:VDOT_QI 4 "register_operand" "vr") + (match_operand:RVVM1SF 2 "register_operand" "0")] + ZVFQWDOT) + (match_dup 2)] UNSPEC_REDUC))] + "TARGET_ZVFQWDOTA8F && TARGET_VECTOR_ELEN_FP_32" + "<dot_asm>.vv\t%0,%3,%4%p1" + [(set_attr "type" "vfdota") + (set_attr "mode" "<MODE>") + (set (attr "altfmt") (symbol_ref "riscv_vector::<dot_altfmt>"))]) + +;; Zvbdota batched dot-product instructions. VTYPE uses LMUL=1; vs2 has +;; EMUL=8 and vs1 has EMUL=1. Eight results are accumulated at offset ci +;; in vd. The intrinsic checker requires capacity for at least eight results. + +(define_insn "@pred_<dot_name>_vv<mode>" + [(set (match_operand:VI_ZVQWBDOTA 0 "register_operand" "=&vr") + (unspec:VI_ZVQWBDOTA + [(unspec:<VM> + [(match_operand:<VM> 1 "vector_mask_operand" "vmWc1") + (match_operand 6 "vector_length_operand" "rvl") + (match_operand 7 "const_int_operand" "i") + (match_operand 8 "const_int_operand" "i") + (match_operand 9 "const_int_operand" "i") + (reg:SI VL_REGNUM) + (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE) + (unspec:VI_ZVQWBDOTA + [(match_operand:<V_QUAD_TRUNC_LMUL8> 3 "register_operand" "vr") + (match_operand:<V_QUAD_TRUNC_LMUL1> 4 "register_operand" "vr") + (match_operand 5 "zvbdota_ci_operand" "i") + (match_operand:VI_ZVQWBDOTA 2 "register_operand" "0")] + ZVQWBDOT) + (match_dup 2)] UNSPEC_REDUC))] + "TARGET_VECTOR" + "<dot_asm>.vv\t%0,%3,%4,%5%p1" + [(set_attr "type" "vibdota") + (set_attr "mode" "<V_QUAD_TRUNC_LMUL1>") + (set (attr "altfmt") (symbol_ref "riscv_vector::<dot_altfmt>"))]) + +(define_insn "@pred_vfwbdota_vv<mode>" + [(set (match_operand:VF_S_NOFRAC 0 "register_operand" "=&vr") + (unspec:VF_S_NOFRAC + [(unspec:<VM> + [(match_operand:<VM> 1 "vector_mask_operand" "vmWc1") + (match_operand 6 "vector_length_operand" "rvl") + (match_operand 7 "const_int_operand" "i") + (match_operand 8 "const_int_operand" "i") + (match_operand 9 "const_int_operand" "i") + (reg:SI VL_REGNUM) + (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE) + (unspec:VF_S_NOFRAC + [(match_operand:RVVM8BF 3 "register_operand" "vr") + (match_operand:RVVM1BF 4 "register_operand" "vr") + (match_operand 5 "zvbdota_ci_operand" "i") + (match_operand:VF_S_NOFRAC 2 "register_operand" "0")] + UNSPEC_VFWBDOTA) + (match_dup 2)] UNSPEC_REDUC))] + "TARGET_ZVFWBDOTA16BF && TARGET_VECTOR_ELEN_BF_16" + "vfwbdota.vv\t%0,%3,%4,%5%p1" + [(set_attr "type" "vfbdota") + (set_attr "mode" "RVVM1BF") + (set (attr "altfmt") (symbol_ref "riscv_vector::ALTFMT_ALT"))]) + +(define_insn "@pred_<dot_name>_vv<mode>" + [(set (match_operand:VF_S_NOFRAC 0 "register_operand" "=&vr") + (unspec:VF_S_NOFRAC + [(unspec:<VM> + [(match_operand:<VM> 1 "vector_mask_operand" "vmWc1") + (match_operand 6 "vector_length_operand" "rvl") + (match_operand 7 "const_int_operand" "i") + (match_operand 8 "const_int_operand" "i") + (match_operand 9 "const_int_operand" "i") + (reg:SI VL_REGNUM) + (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE) + (unspec:VF_S_NOFRAC + [(match_operand:RVVM8QI 3 "register_operand" "vr") + (match_operand:RVVM1QI 4 "register_operand" "vr") + (match_operand 5 "zvbdota_ci_operand" "i") + (match_operand:VF_S_NOFRAC 2 "register_operand" "0")] + ZVFQWBDOT) + (match_dup 2)] UNSPEC_REDUC))] + "TARGET_ZVFQWBDOTA8F" + "<dot_asm>.vv\t%0,%3,%4,%5%p1" + [(set_attr "type" "vfbdota") + (set_attr "mode" "RVVM1QI") + (set (attr "altfmt") (symbol_ref "riscv_vector::<dot_altfmt>"))]) + +(define_insn "@pred_vfbdota_vv<mode>" + [(set (match_operand:VF_S_NOFRAC 0 "register_operand" "=&vr") + (unspec:VF_S_NOFRAC + [(unspec:<VM> + [(match_operand:<VM> 1 "vector_mask_operand" "vmWc1") + (match_operand 6 "vector_length_operand" "rvl") + (match_operand 7 "const_int_operand" "i") + (match_operand 8 "const_int_operand" "i") + (match_operand 9 "const_int_operand" "i") + (match_operand 10 "const_int_operand" "i") + (reg:SI VL_REGNUM) + (reg:SI VTYPE_REGNUM) + (reg:SI FRM_REGNUM)] UNSPEC_VPREDICATE) + (unspec:VF_S_NOFRAC + [(match_operand:RVVM8SF 3 "register_operand" "vr") + (match_operand:RVVM1SF 4 "register_operand" "vr") + (match_operand 5 "zvbdota_ci_operand" "i") + (match_operand:VF_S_NOFRAC 2 "register_operand" "0")] + UNSPEC_VFBDOTA) + (match_dup 2)] UNSPEC_REDUC))] + "TARGET_ZVFBDOTA32F" + "vfbdota.vv\t%0,%3,%4,%5%p1" + [(set_attr "type" "vfbdota") + (set_attr "mode" "RVVM1SF") + (set (attr "frm_mode") + (symbol_ref "riscv_vector::get_frm_mode (operands[10])"))]) diff --git a/gcc/config/riscv/vector-iterators.md b/gcc/config/riscv/vector-iterators.md index f645da120b67..bcf23f2fc37d 100644 --- a/gcc/config/riscv/vector-iterators.md +++ b/gcc/config/riscv/vector-iterators.md @@ -83,6 +83,26 @@ UNSPEC_VFFMA + UNSPEC_VQWDOTA_SS + UNSPEC_VQWDOTA_SU + UNSPEC_VQWDOTA_US + UNSPEC_VQWDOTA_UU + UNSPEC_VFQWDOTA_E4M3_E4M3 + UNSPEC_VFQWDOTA_E4M3_E5M2 + UNSPEC_VFQWDOTA_E5M2_E4M3 + UNSPEC_VFQWDOTA_E5M2_E5M2 + UNSPEC_VQWBDOTA_SS + UNSPEC_VQWBDOTA_SU + UNSPEC_VQWBDOTA_US + UNSPEC_VQWBDOTA_UU + UNSPEC_VFQWBDOTA_E4M3_E4M3 + UNSPEC_VFQWBDOTA_E4M3_E5M2 + UNSPEC_VFQWBDOTA_E5M2_E4M3 + UNSPEC_VFQWBDOTA_E5M2_E5M2 + UNSPEC_VFWDOTA + UNSPEC_VFWBDOTA + UNSPEC_VFBDOTA + UNSPEC_VFMAX UNSPEC_VFMIN @@ -1472,6 +1492,84 @@ (V512DF "riscv_vector::vls_mode_valid_p (V512DFmode) && TARGET_VECTOR_ELEN_FP_64 && TARGET_MIN_VLEN >= 4096") ]) +;; Scalable integer modes with 8-bit elements. +(define_mode_iterator VDOT_QI [ + RVVM8QI RVVM4QI RVVM2QI RVVM1QI RVVMF2QI RVVMF4QI + (RVVMF8QI "TARGET_VECTOR_ELEN_64") +]) + +;; Dot products accept source LMULs through m8 and accumulate into m1. +;; VQEXTI with V_QUAD_TRUNC cannot express the m4 and m8 source modes. +(define_mode_iterator VI_ZVQWDOTA [ + (VDOT_QI "TARGET_ZVQWDOTA8I") + (RVVM8HI "TARGET_ZVQWDOTA16I && TARGET_VECTOR_ELEN_64") + (RVVM4HI "TARGET_ZVQWDOTA16I && TARGET_VECTOR_ELEN_64") + (RVVM2HI "TARGET_ZVQWDOTA16I && TARGET_VECTOR_ELEN_64") + (RVVM1HI "TARGET_ZVQWDOTA16I && TARGET_VECTOR_ELEN_64") + (RVVMF2HI "TARGET_ZVQWDOTA16I && TARGET_VECTOR_ELEN_64") + (RVVMF4HI "TARGET_ZVQWDOTA16I && TARGET_VECTOR_ELEN_64") +]) + +;; Scalable integer accumulator modes for batched dot products. +(define_mode_iterator VI_ZVQWBDOTA [ + (RVVM8SI "TARGET_ZVQWBDOTA8I") + (RVVM4SI "TARGET_ZVQWBDOTA8I") + (RVVM2SI "TARGET_ZVQWBDOTA8I") + (RVVM1SI "TARGET_ZVQWBDOTA8I") + (RVVM8DI "TARGET_ZVQWBDOTA16I && TARGET_VECTOR_ELEN_64") + (RVVM4DI "TARGET_ZVQWBDOTA16I && TARGET_VECTOR_ELEN_64") + (RVVM2DI "TARGET_ZVQWBDOTA16I && TARGET_VECTOR_ELEN_64") + (RVVM1DI "TARGET_ZVQWBDOTA16I && TARGET_VECTOR_ELEN_64") +]) + +;; Scalable single-precision modes with nonfractional LMUL. +(define_mode_iterator VF_S_NOFRAC [ + (RVVM8SF "TARGET_VECTOR_ELEN_FP_32") + (RVVM4SF "TARGET_VECTOR_ELEN_FP_32") + (RVVM2SF "TARGET_VECTOR_ELEN_FP_32") + (RVVM1SF "TARGET_VECTOR_ELEN_FP_32") +]) + +;; Quadruple the element width and use LMUL=1. +(define_mode_attr V_QUAD_EXT_LMUL1 [ + (RVVMF8QI "RVVM1SI") + (RVVMF4QI "RVVM1SI") + (RVVMF2QI "RVVM1SI") + (RVVM1QI "RVVM1SI") + (RVVM2QI "RVVM1SI") + (RVVM4QI "RVVM1SI") + (RVVM8QI "RVVM1SI") + (RVVMF4HI "RVVM1DI") + (RVVMF2HI "RVVM1DI") + (RVVM1HI "RVVM1DI") + (RVVM2HI "RVVM1DI") + (RVVM4HI "RVVM1DI") + (RVVM8HI "RVVM1DI") +]) + +;; Quarter the element width and select a fixed register-group size. +(define_mode_attr V_QUAD_TRUNC_LMUL1 [ + (RVVM1SI "RVVM1QI") + (RVVM2SI "RVVM1QI") + (RVVM4SI "RVVM1QI") + (RVVM8SI "RVVM1QI") + (RVVM1DI "RVVM1HI") + (RVVM2DI "RVVM1HI") + (RVVM4DI "RVVM1HI") + (RVVM8DI "RVVM1HI") +]) + +(define_mode_attr V_QUAD_TRUNC_LMUL8 [ + (RVVM1SI "RVVM8QI") + (RVVM2SI "RVVM8QI") + (RVVM4SI "RVVM8QI") + (RVVM8SI "RVVM8QI") + (RVVM1DI "RVVM8HI") + (RVVM2DI "RVVM8HI") + (RVVM4DI "RVVM8HI") + (RVVM8DI "RVVM8HI") +]) + (define_mode_iterator VOEXTI [ (RVVM8DI "TARGET_VECTOR_ELEN_64") (RVVM4DI "TARGET_VECTOR_ELEN_64") (RVVM2DI "TARGET_VECTOR_ELEN_64") (RVVM1DI "TARGET_VECTOR_ELEN_64") @@ -1768,6 +1866,13 @@ ]) (define_mode_attr V_EXT_LMUL1 [ + (RVVMF4BF "RVVM1SF") + (RVVMF2BF "RVVM1SF") + (RVVM1BF "RVVM1SF") + (RVVM2BF "RVVM1SF") + (RVVM4BF "RVVM1SF") + (RVVM8BF "RVVM1SF") + (RVVM8QI "RVVM1HI") (RVVM4QI "RVVM1HI") (RVVM2QI "RVVM1HI") (RVVM1QI "RVVM1HI") (RVVMF2QI "RVVM1HI") (RVVMF4QI "RVVM1HI") (RVVMF8QI "RVVM1HI") (RVVM8HI "RVVM1SI") (RVVM4HI "RVVM1SI") (RVVM2HI "RVVM1SI") (RVVM1HI "RVVM1SI") (RVVMF2HI "RVVM1SI") (RVVMF4HI "RVVM1SI") @@ -5430,6 +5535,34 @@ (define_int_iterator VFCVTS [UNSPEC_VFCVT UNSPEC_UNSIGNED_VFCVT]) +(define_int_iterator ZVQWDOT [ + UNSPEC_VQWDOTA_SS + UNSPEC_VQWDOTA_SU + UNSPEC_VQWDOTA_US + UNSPEC_VQWDOTA_UU +]) + +(define_int_iterator ZVFQWDOT [ + UNSPEC_VFQWDOTA_E4M3_E4M3 + UNSPEC_VFQWDOTA_E4M3_E5M2 + UNSPEC_VFQWDOTA_E5M2_E4M3 + UNSPEC_VFQWDOTA_E5M2_E5M2 +]) + +(define_int_iterator ZVQWBDOT [ + UNSPEC_VQWBDOTA_SS + UNSPEC_VQWBDOTA_SU + UNSPEC_VQWBDOTA_US + UNSPEC_VQWBDOTA_UU +]) + +(define_int_iterator ZVFQWBDOT [ + UNSPEC_VFQWBDOTA_E4M3_E4M3 + UNSPEC_VFQWBDOTA_E4M3_E5M2 + UNSPEC_VFQWBDOTA_E5M2_E4M3 + UNSPEC_VFQWBDOTA_E5M2_E5M2 +]) + (define_int_attr order [ (UNSPEC_ORDERED "o") (UNSPEC_UNORDERED "u") (UNSPEC_REDUC_SUM_ORDERED "o") (UNSPEC_REDUC_SUM_UNORDERED "u") @@ -5442,6 +5575,64 @@ (UNSPEC_VNCLIP "") (UNSPEC_VNCLIPU "u") (UNSPEC_VFCVT "") (UNSPEC_UNSIGNED_VFCVT "u") (UNSPEC_SF_VFNRCLIP "") (UNSPEC_SF_VFNRCLIPU "u")]) + +(define_int_attr dot_name [ + (UNSPEC_VQWDOTA_SS "vqwdota_ss") + (UNSPEC_VQWDOTA_SU "vqwdota_su") + (UNSPEC_VQWDOTA_US "vqwdota_us") + (UNSPEC_VQWDOTA_UU "vqwdota_uu") + (UNSPEC_VFQWDOTA_E4M3_E4M3 "vfqwdota_e4m3_e4m3") + (UNSPEC_VFQWDOTA_E4M3_E5M2 "vfqwdota_e4m3_e5m2") + (UNSPEC_VFQWDOTA_E5M2_E4M3 "vfqwdota_e5m2_e4m3") + (UNSPEC_VFQWDOTA_E5M2_E5M2 "vfqwdota_e5m2_e5m2") + (UNSPEC_VQWBDOTA_SS "vqwbdota_ss") + (UNSPEC_VQWBDOTA_SU "vqwbdota_su") + (UNSPEC_VQWBDOTA_US "vqwbdota_us") + (UNSPEC_VQWBDOTA_UU "vqwbdota_uu") + (UNSPEC_VFQWBDOTA_E4M3_E4M3 "vfqwbdota_e4m3_e4m3") + (UNSPEC_VFQWBDOTA_E4M3_E5M2 "vfqwbdota_e4m3_e5m2") + (UNSPEC_VFQWBDOTA_E5M2_E4M3 "vfqwbdota_e5m2_e4m3") + (UNSPEC_VFQWBDOTA_E5M2_E5M2 "vfqwbdota_e5m2_e5m2") +]) + +(define_int_attr dot_asm [ + (UNSPEC_VQWDOTA_SS "vqwdotas") + (UNSPEC_VQWDOTA_SU "vqwdotas") + (UNSPEC_VQWDOTA_US "vqwdotau") + (UNSPEC_VQWDOTA_UU "vqwdotau") + (UNSPEC_VFQWDOTA_E4M3_E4M3 "vfqwdota") + (UNSPEC_VFQWDOTA_E4M3_E5M2 "vfqwdota") + (UNSPEC_VFQWDOTA_E5M2_E4M3 "vfqwdota.alt") + (UNSPEC_VFQWDOTA_E5M2_E5M2 "vfqwdota.alt") + (UNSPEC_VQWBDOTA_SS "vqwbdotas") + (UNSPEC_VQWBDOTA_SU "vqwbdotas") + (UNSPEC_VQWBDOTA_US "vqwbdotau") + (UNSPEC_VQWBDOTA_UU "vqwbdotau") + (UNSPEC_VFQWBDOTA_E4M3_E4M3 "vfqwbdota") + (UNSPEC_VFQWBDOTA_E4M3_E5M2 "vfqwbdota") + (UNSPEC_VFQWBDOTA_E5M2_E4M3 "vfqwbdota.alt") + (UNSPEC_VFQWBDOTA_E5M2_E5M2 "vfqwbdota.alt") +]) + +(define_int_attr dot_altfmt [ + (UNSPEC_VQWDOTA_SS "ALTFMT_ALT") + (UNSPEC_VQWDOTA_SU "ALTFMT_NONE") + (UNSPEC_VQWDOTA_US "ALTFMT_ALT") + (UNSPEC_VQWDOTA_UU "ALTFMT_NONE") + (UNSPEC_VFQWDOTA_E4M3_E4M3 "ALTFMT_NONE") + (UNSPEC_VFQWDOTA_E4M3_E5M2 "ALTFMT_ALT") + (UNSPEC_VFQWDOTA_E5M2_E4M3 "ALTFMT_NONE") + (UNSPEC_VFQWDOTA_E5M2_E5M2 "ALTFMT_ALT") + (UNSPEC_VQWBDOTA_SS "ALTFMT_ALT") + (UNSPEC_VQWBDOTA_SU "ALTFMT_NONE") + (UNSPEC_VQWBDOTA_US "ALTFMT_ALT") + (UNSPEC_VQWBDOTA_UU "ALTFMT_NONE") + (UNSPEC_VFQWBDOTA_E4M3_E4M3 "ALTFMT_NONE") + (UNSPEC_VFQWBDOTA_E4M3_E5M2 "ALTFMT_ALT") + (UNSPEC_VFQWBDOTA_E5M2_E4M3 "ALTFMT_NONE") + (UNSPEC_VFQWBDOTA_E5M2_E5M2 "ALTFMT_ALT") +]) + (define_int_attr sat_op [(UNSPEC_VAADDU "aaddu") (UNSPEC_VAADD "aadd") (UNSPEC_VASUBU "asubu") (UNSPEC_VASUB "asub") (UNSPEC_VSMUL "smul") (UNSPEC_VSSRL "ssrl") diff --git a/gcc/config/riscv/vector.md b/gcc/config/riscv/vector.md index 12025181f177..ed16e7d20a9a 100644 --- a/gcc/config/riscv/vector.md +++ b/gcc/config/riscv/vector.md @@ -57,6 +57,7 @@ vror,vwsll,vclmul,vclmulh,vghsh,vgmul,vaesef,vaesem,vaesdf,vaesdm,\ vaeskf1,vaeskf2,vaesz,vsha2ms,vsha2ch,vsha2cl,vsm4k,vsm4r,vsm3me,vsm3c,\ vfncvtbf16,vfwcvtbf16,vfwmaccbf16,sf_vqmacc,sf_vfnrclip,sf_vc,sf_vc_se,\ + vidota,vfdota,vibdota,vfbdota,\ xt_vgmulxor,xt_vcrcfold,xt_vile,xt_vilo") (const_string "true")] (const_string "false"))) @@ -89,6 +90,7 @@ vror,vwsll,vclmul,vclmulh,vghsh,vgmul,vaesef,vaesem,vaesdf,vaesdm,\ vaeskf1,vaeskf2,vaesz,vsha2ms,vsha2ch,vsha2cl,vsm4k,vsm4r,vsm3me,vsm3c,\ vfncvtbf16,vfwcvtbf16,vfwmaccbf16,\ + vidota,vfdota,vibdota,vfbdota,\ xt_vgmulxor,xt_vcrcfold,xt_vile,xt_vilo") (const_string "true")] (const_string "false"))) @@ -510,6 +512,7 @@ vclmul,vclmulh,vghsh,vgmul,vaesef,vaesem,vaesdf,vaesdm,\ vaeskf1,vaeskf2,vaesz,vsha2ms,vsha2ch,vsha2cl,vsm4k,vsm4r,\ vsm3me,vsm3c,vfncvtbf16,vfwcvtbf16,vfwmaccbf16,\ + vidota,vfdota,vibdota,vfbdota,\ xt_vgmulxor,xt_vcrcfold,xt_vile,xt_vilo") (const_int INVALID_ATTRIBUTE) (and (eq_attr "type" "vlde,vste,vlds,vsts,vlsegde,vssegte,vlsegds,\ @@ -839,7 +842,8 @@ xt_vgmulxor,xt_vcrcfold,xt_vile,xt_vilo") (const_int 1) - (eq_attr "type" "vimuladd,vfmuladd") + (eq_attr "type" "vimuladd,vfmuladd,\ + vidota,vfdota,vibdota,vfbdota") (const_int 2)] (const_int INVALID_ATTRIBUTE))) @@ -863,10 +867,14 @@ (const_int 2) (eq_attr "type" "vstux,vstox,vssegts,vssegtux,vssegtox,vfcvtftoi,vfwcvtitof,vfwcvtftoi, - vfwcvtftof,vmsfs,vired,viwred,vfredu,vfredo,vfwredu,vfwredo,vwsll,viwalu,vfwalu,viwmul,vfwmul") + vfwcvtftof,vmsfs,vired,viwred,vfredu,vfredo,\ + vfwredu,vfwredo,vwsll,viwalu,vfwalu,viwmul,\ + vfwmul,\ + vidota,vfdota") (const_int 3) - (eq_attr "type" "viwmuladd,vfwmuladd") + (eq_attr "type" "viwmuladd,vfwmuladd,\ + vibdota,vfbdota") (const_int 4)] (const_int INVALID_ATTRIBUTE))) @@ -895,10 +903,12 @@ vfsgnj,vfmerge,vired,viwred,vfredu,vfredo,vfwredu,vfwredo,\ vslideup,vslidedown,vislide1up,vislide1down,vfslide1up,vfslide1down,\ vgather,viwmuladd,vfwmuladd,vlsegds,vlsegdux,vlsegdox,vandn,vrol,\ - vror,vwsll,vclmul,vclmulh,vfwmaccbf16") + vror,vwsll,vclmul,vclmulh,vfwmaccbf16,\ + vidota,vfdota") (const_int 5) - (eq_attr "type" "vicmp,vimuladd,vfcmp,vfmuladd") + (eq_attr "type" "vicmp,vimuladd,vfcmp,vfmuladd,\ + vibdota,vfbdota") (const_int 6) (eq_attr "type" "vmpop,vmffs,vmidx,vssegte,vcpop,vclz,vctz,vgmul,vaesef,vaesem,vaesdf,\ @@ -931,10 +941,12 @@ vfredo,vfwredu,vfwredo,vslideup,vslidedown,vislide1up,\ vislide1down,vfslide1up,vfslide1down,vgather,viwmuladd,vfwmuladd,\ vlsegds,vlsegdux,vlsegdox,vandn,vrol,vror,vwsll,vclmul,vclmulh,\ - vfwmaccbf16,sf_vqmacc,sf_vfnrclip") + vfwmaccbf16,sf_vqmacc,sf_vfnrclip,\ + vidota,vfdota") (symbol_ref "riscv_vector::get_ta(operands[6])") - (eq_attr "type" "vimuladd,vfmuladd") + (eq_attr "type" "vimuladd,vfmuladd,\ + vibdota,vfbdota") (symbol_ref "riscv_vector::get_ta(operands[7])") (eq_attr "type" "vmidx,vgmul,vaesef,vaesem,vaesdf,vaesdm,vaesz,vsm4r") @@ -962,10 +974,13 @@ vfwalu,vfwmul,vfsgnj,vfcmp,vslideup,vslidedown,\ vislide1up,vislide1down,vfslide1up,vfslide1down,vgather,\ viwmuladd,vfwmuladd,vlsegds,vlsegdux,vlsegdox,vandn,vrol,\ - vror,vwsll,vclmul,vclmulh,vfwmaccbf16,sf_vqmacc,sf_vfnrclip") + vror,vwsll,vclmul,vclmulh,vfwmaccbf16,sf_vqmacc,\ + sf_vfnrclip,\ + vidota,vfdota") (symbol_ref "riscv_vector::get_ma(operands[7])") - (eq_attr "type" "vimuladd,vfmuladd") + (eq_attr "type" "vimuladd,vfmuladd,\ + vibdota,vfbdota") (symbol_ref "riscv_vector::get_ma(operands[8])") (eq_attr "type" "vmsfs,vmidx") @@ -998,12 +1013,14 @@ vfsgnj,vfcmp,vslideup,vslidedown,vislide1up,\ vislide1down,vfslide1up,vfslide1down,vgather,viwmuladd,vfwmuladd,\ vlsegds,vlsegdux,vlsegdox,vandn,vrol,vror,vclmul,vclmulh,vwsll,\ - vfwmaccbf16") + vfwmaccbf16,\ + vidota,vfdota") (const_int 8) (eq_attr "type" "vstux,vstox,vssegts,vssegtux,vssegtox") (const_int 5) - (eq_attr "type" "vimuladd,vfmuladd") + (eq_attr "type" "vimuladd,vfmuladd,\ + vibdota,vfbdota") (const_int 9) (eq_attr "type" "vmsfs,vmidx,vcompress,vghsh,vaeskf1,vaeskf2,vsha2ms,vsha2ch,vsha2cl,\ diff --git a/gcc/config/riscv/xiangshan.md b/gcc/config/riscv/xiangshan.md index b15e845b381f..de2f46ef679e 100644 --- a/gcc/config/riscv/xiangshan.md +++ b/gcc/config/riscv/xiangshan.md @@ -107,7 +107,31 @@ ;; they are just dummies like this one. (define_insn_reservation "xiangshan_alu_unknown" 1 (and (eq_attr "tune" "xiangshan") - (eq_attr "type" "zicond,min,max,minu,maxu,clz,ctz,cpop,ghost,rotate,clmul,condmove,crypto,mvpair,rdvlenb,rdvl,wrvxrm,wrfrm,rdfrm,vsetvl,vsetvl_pre,vlde,vste,vldm,vstm,vlds,vsts,vldux,vldox,vstux,vstox,vldff,vldr,vstr,vlsegde,vssegte,vlsegds,vssegts,vlsegdux,vlsegdox,vssegtux,vssegtox,vlsegdff,vialu,viwalu,vext,vicalu,vshift,vnshift,vicmp,viminmax,vimul,vidiv,viwmul,vimuladd,sf_vqmacc,viwmuladd,vimerge,vimov,vsalu,vaalu,vsmul,vsshift,vnclip,sf_vfnrclip,vfalu,vfwalu,vfmul,vfdiv,vfwmul,vfmuladd,vfwmuladd,vfsqrt,vfrecp,vfcmp,vfminmax,vfsgnj,vfclass,vfmerge,vfmov,vfcvtitof,vfcvtftoi,vfwcvtitof,vfwcvtftoi,vfwcvtftof,vfncvtitof,vfncvtftoi,vfncvtftof,vired,viwred,vfredu,vfredo,vfwredu,vfwredo,vmalu,vmpop,vmffs,vmsfs,vmiota,vmidx,vimovvx,vimovxv,vfmovvf,vfmovfv,vslideup,vslidedown,vislide1up,vislide1down,vfslide1up,vfslide1down,vgather,vcompress,vmov,vector,vandn,vbrev,vbrev8,vrev8,vclz,vctz,vcpop,vrol,vror,vwsll,vclmul,vclmulh,vghsh,vgmul,vaesef,vaesem,vaesdf,vaesdm,vaeskf1,vaeskf2,v aesz,vsha2ms,vsha2ch,vsha2cl,vsm4k,vsm4r,vsm3me,vsm3c,vfncvtbf16,vfwcvtbf16,vfwmaccbf16,sf_vc,sf_vc_se,xt_vgmulxor,xt_vcrcfold,xt_vile,xt_vilo")) + (eq_attr "type" "zicond,min,max,minu,maxu,clz,ctz,cpop,ghost, + rotate,clmul,condmove,crypto,mvpair,rdvlenb,rdvl, + wrvxrm,wrfrm,rdfrm,vsetvl,vsetvl_pre,vlde,vste, + vldm,vstm,vlds,vsts,vldux,vldox,vstux,vstox,vldff, + vldr,vstr,vlsegde,vssegte,vlsegds,vssegts, + vlsegdux,vlsegdox,vssegtux,vssegtox,vlsegdff, + vialu,viwalu,vext,vicalu,vshift,vnshift,vicmp, + viminmax,vimul,vidiv,viwmul,vimuladd,sf_vqmacc, + viwmuladd,vimerge,vimov,vsalu,vaalu,vsmul,vsshift, + vnclip,sf_vfnrclip,vfalu,vfwalu,vfmul,vfdiv, + vfwmul,vfmuladd,vfwmuladd,vfsqrt,vfrecp,vfcmp, + vfminmax,vfsgnj,vfclass,vfmerge,vfmov,vfcvtitof, + vfcvtftoi,vfwcvtitof,vfwcvtftoi,vfwcvtftof, + vfncvtitof,vfncvtftoi,vfncvtftof,vired,viwred, + vfredu,vfredo,vfwredu,vfwredo,vmalu,vmpop,vmffs, + vmsfs,vmiota,vmidx,vimovvx,vimovxv,vfmovvf, + vfmovfv,vslideup,vslidedown,vislide1up, + vislide1down,vfslide1up,vfslide1down,vgather, + vcompress,vmov,vector,vandn,vbrev,vbrev8,vrev8, + vclz,vctz,vcpop,vrol,vror,vwsll,vclmul,vclmulh, + vghsh,vgmul,vaesef,vaesem,vaesdf,vaesdm,vaeskf1, + vaeskf2,vaesz,vsha2ms,vsha2ch,vsha2cl,vsm4k,vsm4r, + vsm3me,vsm3c,vfncvtbf16,vfwcvtbf16,vfwmaccbf16, + sf_vc,sf_vc_se,vidota,vfdota,vibdota,vfbdota, + xt_vgmulxor,xt_vcrcfold,xt_vile,xt_vilo")) "xs_alu_rs") diff --git a/gcc/config/riscv/xt-c908.md b/gcc/config/riscv/xt-c908.md index 32e4ad21ae93..0456f3f81d83 100644 --- a/gcc/config/riscv/xt-c908.md +++ b/gcc/config/riscv/xt-c908.md @@ -134,5 +134,6 @@ vshift,vslidedown,vslideup,vsm3c,vsm3me,vsm4k,vsm4r, vsmul,vssegte,vssegtox,vssegts,vssegtux,vsshift,vste, vstm,vstox,vstr,vsts,vstux,vwsll,wrfrm,wrvxrm, - xt_vgmulxor,xt_vcrcfold,xt_vile,xt_vilo")) + xt_vgmulxor,xt_vcrcfold,xt_vile,xt_vilo, + vidota,vfdota,vibdota,vfbdota")) "nothing")
