https://gcc.gnu.org/g:55abb0d57c28855b831c6f91a615ebe6fd9590f7

commit r16-2423-g55abb0d57c28855b831c6f91a615ebe6fd9590f7
Author: Jeff Law <j...@ventanamicro.com>
Date:   Tue Jul 22 07:26:57 2025 -0600

    [RISC-V] Restrict generic-vector-ooo DFA
    
    So while debugging Austin's work to support the spacemit x60 in the BPI we
    found that even though his pipeline description had mappings for all the 
vector
    instructions, they were still getting matched by the generic-vector-ooo DFA.
    
    The core problem is that DFA never restricted itself to a tune option 
(oops).
    That's easily fixed, at which time everything using generic blows up 
because we
    don't have a generic in-order vector DFA. Everything using generic was
    indirectly also using generic-vector-ooo for the vector instructions.
    
    It may be better long term to define a generic-vector DFA, but to preserve
    behavior, I'm letting generic-vector-ooo match when the generic DFA is 
active.
    
    Tested in my tester, waiting on pre-commit CI before moving forward.
    
    gcc/
            * config/riscv/generic-vector-ooo.md: Restrict insn reservations to
            generic_ooo and generic tuning models.

Diff:
---
 gcc/config/riscv/generic-vector-ooo.md | 85 ++++++++++++++++++++++------------
 1 file changed, 55 insertions(+), 30 deletions(-)

diff --git a/gcc/config/riscv/generic-vector-ooo.md 
b/gcc/config/riscv/generic-vector-ooo.md
index ab9e57f5cbf7..773003b49aeb 100644
--- a/gcc/config/riscv/generic-vector-ooo.md
+++ b/gcc/config/riscv/generic-vector-ooo.md
@@ -17,6 +17,9 @@
 ;; <http://www.gnu.org/licenses/>.
 ;; Vector load/store
 
+;; The insn reservations include "generic" as we won't have a in-order
+;; generic definition for vector instructions.
+
 (define_automaton "vector_ooo")
 
 ;; Separate issue queue for vector instructions.
@@ -29,119 +32,141 @@
 (define_cpu_unit "vxu_ooo_multicycle" "vector_ooo")
 
 (define_insn_reservation "vec_load" 6
-  (eq_attr "type" "vlde,vldm,vlds,vldux,vldox,vldff,vldr")
+  (and (eq_attr "tune" "generic_ooo,generic")
+       (eq_attr "type" "vlde,vldm,vlds,vldux,vldox,vldff,vldr"))
   "vxu_ooo_issue,vxu_ooo_alu")
 
 (define_insn_reservation "vec_store" 6
-  (eq_attr "type" "vste,vstm,vsts,vstux,vstox,vstr")
+  (and (eq_attr "tune" "generic_ooo,generic")
+       (eq_attr "type" "vste,vstm,vsts,vstux,vstox,vstr"))
   "vxu_ooo_issue,vxu_ooo_alu")
 
 ;; Vector segment loads/stores.
 (define_insn_reservation "vec_loadstore_seg" 10
-  (eq_attr "type" "vlsegde,vlsegds,vlsegdux,vlsegdox,vlsegdff,\
-                  vssegte,vssegts,vssegtux,vssegtox")
+  (and (eq_attr "tune" "generic_ooo,generic")
+       (eq_attr "type" "vlsegde,vlsegds,vlsegdux,vlsegdox,vlsegdff,\
+                       vssegte,vssegts,vssegtux,vssegtox"))
   "vxu_ooo_issue,vxu_ooo_alu")
 
 ;; Regular vector operations and integer comparisons.
 (define_insn_reservation "vec_alu" 3
-  (eq_attr "type" "vialu,viwalu,vext,vicalu,vshift,vnshift,viminmax,vicmp,\
-                  vimov,vsalu,vaalu,vsshift,vnclip,vmov,vfmov,vector,\
-                  vandn,vbrev,vbrev8,vrev8,vclz,vctz,vrol,vror,vwsll")
+  (and (eq_attr "tune" "generic_ooo,generic")
+       (eq_attr "type" 
"vialu,viwalu,vext,vicalu,vshift,vnshift,viminmax,vicmp,\
+                       vimov,vsalu,vaalu,vsshift,vnclip,vmov,vfmov,vector,\
+                       vandn,vbrev,vbrev8,vrev8,vclz,vctz,vrol,vror,vwsll"))
   "vxu_ooo_issue,vxu_ooo_alu")
 
 ;; Vector float comparison, conversion etc.
 (define_insn_reservation "vec_fcmp" 3
-  (eq_attr "type" "vfrecp,vfminmax,vfcmp,vfsgnj,vfclass,vfcvtitof,\
-                   vfcvtftoi,vfwcvtitof,vfwcvtftoi,vfwcvtftof,vfncvtitof,\
-                   vfncvtftoi,vfncvtftof,vfncvtbf16,vfwcvtbf16")
+  (and (eq_attr "tune" "generic_ooo,generic")
+       (eq_attr "type" "vfrecp,vfminmax,vfcmp,vfsgnj,vfclass,vfcvtitof,\
+                        vfcvtftoi,vfwcvtitof,vfwcvtftoi,vfwcvtftof,vfncvtitof,\
+                        vfncvtftoi,vfncvtftof,vfncvtbf16,vfwcvtbf16"))
   "vxu_ooo_issue,vxu_ooo_alu")
 
 ;; Vector integer multiplication.
 (define_insn_reservation "vec_imul" 4
-  (eq_attr "type" "vimul,viwmul,vimuladd,viwmuladd,vsmul,vclmul,vclmulh,\
-                   vghsh,vgmul")
+  (and (eq_attr "tune" "generic_ooo,generic")
+       (eq_attr "type" "vimul,viwmul,vimuladd,viwmuladd,vsmul,vclmul,vclmulh,\
+                        vghsh,vgmul"))
   "vxu_ooo_issue,vxu_ooo_alu")
 
 ;; Vector float addition.
 (define_insn_reservation "vec_fadd" 4
-  (eq_attr "type" "vfalu,vfwalu")
+  (and (eq_attr "tune" "generic_ooo,generic")
+       (eq_attr "type" "vfalu,vfwalu"))
   "vxu_ooo_issue,vxu_ooo_alu")
 
 ;; Vector float multiplication and FMA.
 (define_insn_reservation "vec_fmul" 6
-  (eq_attr "type" 
"vfmul,vfwmul,vfmuladd,vfwmuladd,vfwmaccbf16,sf_vqmacc,sf_vfnrclip")
+  (and (eq_attr "tune" "generic_ooo,generic")
+       (eq_attr "type" 
"vfmul,vfwmul,vfmuladd,vfwmuladd,vfwmaccbf16,sf_vqmacc,sf_vfnrclip"))
   "vxu_ooo_issue,vxu_ooo_alu")
 
 ;; Vector crypto, assumed to be a generic operation for now.
 (define_insn_reservation "vec_crypto" 4
-  (eq_attr "type" "crypto,vclz,vctz,vcpop")
+  (and (eq_attr "tune" "generic_ooo,generic")
+       (eq_attr "type" "crypto,vclz,vctz,vcpop"))
   "vxu_ooo_issue,vxu_ooo_alu")
 
 ;; Vector crypto, AES
 (define_insn_reservation "vec_crypto_aes" 4
-  (eq_attr "type" "vaesef,vaesem,vaesdf,vaesdm,vaeskf1,vaeskf2,vaesz")
+  (and (eq_attr "tune" "generic_ooo,generic")
+       (eq_attr "type" "vaesef,vaesem,vaesdf,vaesdm,vaeskf1,vaeskf2,vaesz"))
   "vxu_ooo_issue,vxu_ooo_alu")
 
 ;; Vector crypto, sha
 (define_insn_reservation "vec_crypto_sha" 4
-  (eq_attr "type" "vsha2ms,vsha2ch,vsha2cl")
+  (and (eq_attr "tune" "generic_ooo,generic")
+       (eq_attr "type" "vsha2ms,vsha2ch,vsha2cl"))
   "vxu_ooo_issue,vxu_ooo_alu")
 
 ;; Vector crypto, SM3/4
 (define_insn_reservation "vec_crypto_sm" 4
-  (eq_attr "type" "vsm4k,vsm4r,vsm3me,vsm3c")
+  (and (eq_attr "tune" "generic_ooo,generic")
+       (eq_attr "type" "vsm4k,vsm4r,vsm3me,vsm3c"))
   "vxu_ooo_issue,vxu_ooo_alu")
 
 ;; Vector permute.
 (define_insn_reservation "vec_perm" 3
-  (eq_attr "type" "vimerge,vfmerge,vslideup,vslidedown,vislide1up,\
-                   vislide1down,vfslide1up,vfslide1down,vgather,vcompress")
+  (and (eq_attr "tune" "generic_ooo,generic")
+       (eq_attr "type" "vimerge,vfmerge,vslideup,vslidedown,vislide1up,\
+                        
vislide1down,vfslide1up,vfslide1down,vgather,vcompress"))
   "vxu_ooo_issue,vxu_ooo_alu")
 
 ;; Vector reduction.
 (define_insn_reservation "vec_reduction" 8
-  (eq_attr "type" "vired,viwred,vfredu,vfwredu")
+  (and (eq_attr "tune" "generic_ooo,generic")
+       (eq_attr "type" "vired,viwred,vfredu,vfwredu"))
   "vxu_ooo_issue,vxu_ooo_multicycle")
 
 ;; Vector ordered reduction, assume the latency number is for
 ;; a 128-bit vector.  It is scaled in riscv_sched_adjust_cost
 ;; for larger vectors.
 (define_insn_reservation "vec_ordered_reduction" 10
-  (eq_attr "type" "vfredo,vfwredo")
+  (and (eq_attr "tune" "generic_ooo,generic")
+       (eq_attr "type" "vfredo,vfwredo"))
   "vxu_ooo_issue,vxu_ooo_multicycle*3")
 
 ;; Vector integer division, assume not pipelined.
 (define_insn_reservation "vec_idiv" 16
-  (eq_attr "type" "vidiv")
+  (and (eq_attr "tune" "generic_ooo,generic")
+       (eq_attr "type" "vidiv"))
   "vxu_ooo_issue,vxu_ooo_multicycle*3")
 
 ;; Vector float divisions and sqrt, assume not pipelined.
 (define_insn_reservation "vec_float_divsqrt" 16
-  (eq_attr "type" "vfdiv,vfsqrt")
+  (and (eq_attr "tune" "generic_ooo,generic")
+       (eq_attr "type" "vfdiv,vfsqrt"))
   "vxu_ooo_issue,vxu_ooo_multicycle*3")
 
 ;; Vector mask operations.
 (define_insn_reservation "vec_mask" 2
-  (eq_attr "type" "vmalu,vmpop,vmffs,vmsfs,vmiota,vmidx,vimovvx,vimovxv,\
-                   vfmovvf,vfmovfv")
+  (and (eq_attr "tune" "generic_ooo,generic")
+       (eq_attr "type" "vmalu,vmpop,vmffs,vmsfs,vmiota,vmidx,vimovvx,vimovxv,\
+                        vfmovvf,vfmovfv"))
   "vxu_ooo_issue,vxu_ooo_alu")
 
 ;; Vector vsetvl.
 (define_insn_reservation "vec_vesetvl" 1
-  (eq_attr "type" "vsetvl,vsetvl_pre")
+  (and (eq_attr "tune" "generic_ooo,generic")
+       (eq_attr "type" "vsetvl,vsetvl_pre"))
   "vxu_ooo_issue")
 
 ;; Vector rounding mode setters, assume pipeline barrier.
 (define_insn_reservation "vec_setrm" 20
-  (eq_attr "type" "wrvxrm,wrfrm")
+  (and (eq_attr "tune" "generic_ooo,generic")
+       (eq_attr "type" "wrvxrm,wrfrm"))
   "vxu_ooo_issue,vxu_ooo_issue*3")
 
 ;; Vector read vlen/vlenb.
 (define_insn_reservation "vec_readlen" 4
-  (eq_attr "type" "rdvlenb,rdvl")
+  (and (eq_attr "tune" "generic_ooo,generic")
+       (eq_attr "type" "rdvlenb,rdvl"))
   "vxu_ooo_issue,vxu_ooo_issue")
 
 ;; Vector sf_vcp.
 (define_insn_reservation "vec_sf_vcp" 2
-  (eq_attr "type" "sf_vc,sf_vc_se")
+  (and (eq_attr "tune" "generic_ooo,generic")
+       (eq_attr "type" "sf_vc,sf_vc_se"))
   "vxu_ooo_issue")

Reply via email to