https://gcc.gnu.org/g:b88c2821e219244d18df873b0bfb344d3dc0b2a7

commit r17-5905-gb88c2821e219244d18df873b0bfb344d3dc0b2a7
Author: Loeka Rogge <[email protected]>
Date:   Thu Oct 15 14:08:28 2026 +0200

    RISC-V: Add ARC-V RPX-100 series pipeline description
    
    The RPX-100 pipeline is the same design as the RHX-100 but RV64 instead
    of RV32. This mtune is just an alias and adds 64 bit multiplication.
    
    Add a mul_part attribute to al multiplication instructions in riscv.md
    to distinguish instructions that return the high and low part.
    
    Regtested on rv32gc, rv64gc and with rhx100 config and mtune.
    
    gcc/ChangeLog:
    
            * config/riscv/arcv-rhx100.md (arcv_rhx100_mpy_insn): Rename to
            mpy32.
            (arcv_rhx100_mpy32_insn): Also apply for rpx_100 tune.
            (arcv_rhx100_mpy64l_insn): rpx_100 mul low part.
            (arcv_rhx100_mpy64h_insn): rpx_100 mul high part.
            (arcv_rhx100_mpy*_insn): Apply bypass for both size mul.
            (arcv_rhx100_div_insn): Also apply for rpx_100 tune.
            (riscv_store_data_bypass_p): Add store bypass
            (arcv_rhx100_store_insn): Likewise.
            (arcv_rhx100_load_insn): Add load bypass.
            * config/riscv/riscv-cores.def (RISCV_TUNE):
            Add arcv_rpx100 tune
            * config/riscv/riscv-opts.h (enum riscv_microarchitecture_type):
            Add arcv_rpx100 microarchitecture type
            * config/riscv/riscv.md (low,high): Add low/high mul_part
            attribute, default value: low.
            * doc/riscv-mtune.texi: Add rpx_100 tune
    
    gcc/testsuite/ChangeLog:
    
            * gcc.target/riscv/arcv-sched-mul-mem-rpx100.c: New test.
    
    Signed-off-by: Loeka Rogge <[email protected]>

Diff:
---
 gcc/config/riscv/arcv-rhx100.md                    | 57 ++++++++++-----
 gcc/config/riscv/riscv-cores.def                   |  1 +
 gcc/config/riscv/riscv-opts.h                      |  1 +
 gcc/config/riscv/riscv.md                          | 18 +++--
 gcc/doc/riscv-mtune.texi                           |  2 +
 .../gcc.target/riscv/arcv-sched-mul-mem-rpx100.c   | 80 ++++++++++++++++++++++
 6 files changed, 138 insertions(+), 21 deletions(-)

diff --git a/gcc/config/riscv/arcv-rhx100.md b/gcc/config/riscv/arcv-rhx100.md
index 24855f257dbd..72f0147ea364 100644
--- a/gcc/config/riscv/arcv-rhx100.md
+++ b/gcc/config/riscv/arcv-rhx100.md
@@ -1,4 +1,4 @@
-;; DFA scheduling description of the Synopsys RHX-100 cpu
+;; DFA scheduling description of the ARC-V RHX-100 and RPX-100 cpu
 ;; for GNU C compiler
 ;; Copyright (C) 2026 Free Software Foundation, Inc.
 
@@ -36,55 +36,72 @@
 
 ;; Instruction reservation for arithmetic instructions (pipe A, pipe B).
 (define_insn_reservation "arcv_rhx100_alu_early_arith" 1
-  (and (eq_attr "tune" "arcv_rhx100")
+  (and (eq_attr "tune" "arcv_rhx100,arcv_rpx100")
        (eq_attr "type" 
"unknown,move,const,arith,shift,slt,multi,auipc,nop,logical,\
                bitmanip,min,max,minu,maxu,clz,ctz,atomic,\
                condmove,mvpair,zicond,cpop,clmul,rotate"))
   "((arcv_rhx100_issueA_fuse0 + arcv_rhx100_ALU_A_fuse0_early) | 
(arcv_rhx100_issueA_fuse1 + arcv_rhx100_ALU_A_fuse1_early)) | 
((arcv_rhx100_issueB_fuse0 + arcv_rhx100_ALU_B_fuse0_early) | 
(arcv_rhx100_issueB_fuse1 + arcv_rhx100_ALU_B_fuse1_early))")
 
 (define_insn_reservation "arcv_rhx100_jmp_insn" 1
-  (and (eq_attr "tune" "arcv_rhx100")
+  (and (eq_attr "tune" "arcv_rhx100,arcv_rpx100")
        (eq_attr "type" "branch,jump,call,jalr,ret,trap"))
   "arcv_rhx100_issueA_fuse0 | arcv_rhx100_issueA_fuse1")
 
 (define_insn_reservation "arcv_rhx100_div_insn" 12
-  (and (eq_attr "tune" "arcv_rhx100")
+  (and (eq_attr "tune" "arcv_rhx100,arcv_rpx100")
        (eq_attr "type" "idiv"))
   "arcv_rhx100_issueA_fuse0 + arcv_rhx100_DIV")
 
-(define_insn_reservation "arcv_rhx100_mpy_insn" 4
-  (and (eq_attr "tune" "arcv_rhx100")
-       (eq_attr "type" "imul"))
+(define_insn_reservation "arcv_rhx100_mpy32_insn" 4
+  (ior (and (eq_attr "tune" "arcv_rhx100")
+           (eq_attr "type" "imul"))
+       (and (eq_attr "tune" "arcv_rpx100")
+           (eq_attr "type" "imul")
+           (eq_attr "mode" "SI")))
   "arcv_rhx100_issueA_fuse0 + arcv_rhx100_MPY")
 
+(define_insn_reservation "arcv_rhx100_mpy64l_insn" 6
+  (and (eq_attr "tune" "arcv_rpx100")
+       (eq_attr "type" "imul")
+       (eq_attr "mode" "DI")
+       (eq_attr "mul_part" "low"))
+  "arcv_rhx100_issueA_fuse0 + arcv_rhx100_MPY, arcv_rhx100_MPY*2")
+
+(define_insn_reservation "arcv_rhx100_mpy64h_insn" 7
+  (and (eq_attr "tune" "arcv_rpx100")
+       (eq_attr "type" "imul")
+       (eq_attr "mode" "DI")
+       (eq_attr "mul_part" "high"))
+  "arcv_rhx100_issueA_fuse0 + arcv_rhx100_MPY, arcv_rhx100_MPY*3")
+
 (define_insn_reservation "arcv_rhx100_load_insn" 3
-  (and (eq_attr "tune" "arcv_rhx100")
+  (and (eq_attr "tune" "arcv_rhx100,arcv_rpx100")
        (eq_attr "type" "load,fpload"))
   "(arcv_rhx100_issueB_fuse0 + arcv_rhx100_DMP_fuse0) | 
(arcv_rhx100_issueB_fuse1 + arcv_rhx100_DMP_fuse1)")
 
 (define_insn_reservation "arcv_rhx100_store_insn" 1
-  (and (eq_attr "tune" "arcv_rhx100")
+  (and (eq_attr "tune" "arcv_rhx100,arcv_rpx100")
        (eq_attr "type" "store,fpstore"))
   "(arcv_rhx100_issueB_fuse0 + arcv_rhx100_DMP_fuse0) | 
(arcv_rhx100_issueB_fuse1 + arcv_rhx100_DMP_fuse1)")
 
 ;; (soft) floating points
 (define_insn_reservation "arcv_rhx100_xfer" 3
-  (and (eq_attr "tune" "arcv_rhx100")
+  (and (eq_attr "tune" "arcv_rhx100,arcv_rpx100")
        (eq_attr "type" "mfc,mtc,fcvt,fcvt_i2f,fcvt_f2i,fmove,fcmp"))
   "(arcv_rhx100_ALU_A_fuse0_early | arcv_rhx100_ALU_B_fuse0_early)")
 
 (define_insn_reservation "arcv_rhx100_fmul" 5
-  (and (eq_attr "tune" "arcv_rhx100")
+  (and (eq_attr "tune" "arcv_rhx100,arcv_rpx100")
        (eq_attr "type" "fadd,fmul,fmadd"))
   "(arcv_rhx100_ALU_A_fuse0_early | arcv_rhx100_ALU_B_fuse0_early)")
 
 (define_insn_reservation "arcv_rhx100_fdiv" 20
-  (and (eq_attr "tune" "arcv_rhx100")
+  (and (eq_attr "tune" "arcv_rhx100,arcv_rpx100")
        (eq_attr "type" "fdiv,fsqrt"))
   "arcv_rhx100_fdivsqrt*7")
 
 (define_insn_reservation "arcv_rhx100_unknown" 5
-  (and (eq_attr "tune" "arcv_rhx100")
+  (and (eq_attr "tune" "arcv_rhx100,arcv_rpx100")
        (eq_attr "type" "vfwalu,vfwcvtftoi,vrol,vmidx,vext,vaeskf1,vfredo,
                         vector,sfb_alu,vlds,viminmax,vfcmp,vimov,vsmul,vnclip,
                         vldm,vsetvl_pre,vwsll,vfmerge,vmffs,vclmul,vmpop,wrfrm,
@@ -112,9 +129,17 @@
 
 (define_bypass 1 "arcv_rhx100_load_insn" "arcv_rhx100_store_insn" 
"riscv_store_data_bypass_p")
 (define_bypass 1 "arcv_rhx100_load_insn" "arcv_rhx100_alu_early_arith")
-(define_bypass 1 "arcv_rhx100_load_insn" "arcv_rhx100_mpy_insn")
+(define_bypass 1 "arcv_rhx100_load_insn" "arcv_rhx100_mpy*_insn")
 (define_bypass 2 "arcv_rhx100_load_insn" "arcv_rhx100_load_insn")
 (define_bypass 1 "arcv_rhx100_load_insn" "arcv_rhx100_div_insn")
 
-(define_bypass 3 "arcv_rhx100_mpy_insn" "arcv_rhx100_mpy_insn")
-(define_bypass 3 "arcv_rhx100_mpy_insn" "arcv_rhx100_div_insn")
+(define_bypass 3 "arcv_rhx100_mpy32*_insn" "arcv_rhx100_mpy*_insn")
+(define_bypass 3 "arcv_rhx100_mpy32*_insn" "arcv_rhx100_div_insn")
+(define_bypass 1 "arcv_rhx100_mpy*_insn" "arcv_rhx100_store_insn" 
"riscv_store_data_bypass_p")
+(define_bypass 7 "arcv_rhx100_mpy32*_insn" "arcv_rhx100_store_insn")
+(define_bypass 7 "arcv_rhx100_mpy32*_insn" "arcv_rhx100_load_insn")
+
+(define_bypass 9 "arcv_rhx100_mpy64l_insn" "arcv_rhx100_load_insn")
+(define_bypass 9 "arcv_rhx100_mpy64l_insn" "arcv_rhx100_store_insn")
+(define_bypass 10 "arcv_rhx100_mpy64h_insn" "arcv_rhx100_load_insn")
+(define_bypass 10 "arcv_rhx100_mpy64h_insn" "arcv_rhx100_store_insn")
diff --git a/gcc/config/riscv/riscv-cores.def b/gcc/config/riscv/riscv-cores.def
index e8416498d667..155caf138524 100644
--- a/gcc/config/riscv/riscv-cores.def
+++ b/gcc/config/riscv/riscv-cores.def
@@ -58,6 +58,7 @@ RISCV_TUNE("spacemit-x60", spacemit_x60, 
spacemit_x60_tune_info)
 RISCV_TUNE("spacemit-x100", generic_ooo, spacemit_x100_tune_info)
 RISCV_TUNE("spacemit-a100", spacemit_x60, spacemit_x60_tune_info)
 RISCV_TUNE("arc-v-rhx-100-series", arcv_rhx100, arcv_rhx100_tune_info)
+RISCV_TUNE("arc-v-rpx-100-series", arcv_rpx100, arcv_rhx100_tune_info)
 RISCV_TUNE("generic-ooo", generic_ooo, generic_ooo_tune_info)
 RISCV_TUNE("size", generic, optimize_size_tune_info)
 RISCV_TUNE("mips-p8700", mips_p8700, mips_p8700_tune_info)
diff --git a/gcc/config/riscv/riscv-opts.h b/gcc/config/riscv/riscv-opts.h
index 8711031d7093..c5f8057ccbfa 100644
--- a/gcc/config/riscv/riscv-opts.h
+++ b/gcc/config/riscv/riscv-opts.h
@@ -68,6 +68,7 @@ enum riscv_microarchitecture_type {
   spacemit_x60,
   arcv_rmx100,
   arcv_rhx100,
+  arcv_rpx100,
   xt_c908
 };
 extern enum riscv_microarchitecture_type riscv_microarchitecture;
diff --git a/gcc/config/riscv/riscv.md b/gcc/config/riscv/riscv.md
index 47e83e876305..bc8e7106e52f 100644
--- a/gcc/config/riscv/riscv.md
+++ b/gcc/config/riscv/riscv.md
@@ -678,12 +678,16 @@
 ;; Is copying of this instruction disallowed?
 (define_attr "cannot_copy" "no,yes" (const_string "no"))
 
+;; Multiply part attribute distinguishes mul (low) from mulh/mulhu/mulhsu 
(high)
+(define_attr "mul_part" "low,high"
+  (const_string "low"))
+
 ;; Microarchitectures we know how to tune for.
 ;; Keep this in sync with enum riscv_microarchitecture.
 (define_attr "tune"
   "generic,sifive_7,sifive_p400,sifive_p600,xiangshan,generic_ooo,mips_p8700,
    tt_ascalon_d8,tt_ascalon_xg,andes_25_series,andes_23_series,andes_45_series,
-   spacemit_x60,arcv_rmx100,arcv_rhx100,xt_c908"
+   spacemit_x60,arcv_rmx100,arcv_rhx100,arcv_rpx100,xt_c908"
   (const (symbol_ref "((enum attr_tune) riscv_microarchitecture)")))
 
 ;; Describe a user's asm statement.
@@ -1314,7 +1318,8 @@
   "(TARGET_ZMMUL || TARGET_MUL) && TARGET_64BIT"
   "mulh<u>\t%0,%1,%2"
   [(set_attr "type" "imul")
-   (set_attr "mode" "DI")])
+   (set_attr "mode" "DI")
+   (set_attr "mul_part" "high")])
 
 (define_expand "usmulditi3"
   [(set (match_operand:TI                          0 "register_operand")
@@ -1345,7 +1350,8 @@
   "(TARGET_ZMMUL || TARGET_MUL) && TARGET_64BIT"
   "mulhsu\t%0,%2,%1"
   [(set_attr "type" "imul")
-   (set_attr "mode" "DI")])
+   (set_attr "mode" "DI")
+   (set_attr "mul_part" "high")])
 
 (define_expand "<u>mulsidi3"
   [(set (match_operand:DI            0 "register_operand" "=r")
@@ -1375,7 +1381,8 @@
   "(TARGET_ZMMUL || TARGET_MUL) && !TARGET_64BIT"
   "mulh<u>\t%0,%1,%2"
   [(set_attr "type" "imul")
-   (set_attr "mode" "SI")])
+   (set_attr "mode" "SI")
+   (set_attr "mul_part" "high")])
 
 
 (define_expand "usmulsidi3"
@@ -1406,7 +1413,8 @@
   "(TARGET_ZMMUL || TARGET_MUL) && !TARGET_64BIT"
   "mulhsu\t%0,%2,%1"
   [(set_attr "type" "imul")
-   (set_attr "mode" "SI")])
+   (set_attr "mode" "SI")
+   (set_attr "mul_part" "high")])
 
 ;;
 ;;  ....................
diff --git a/gcc/doc/riscv-mtune.texi b/gcc/doc/riscv-mtune.texi
index 2070e6cd55f8..2f4bade90ce9 100644
--- a/gcc/doc/riscv-mtune.texi
+++ b/gcc/doc/riscv-mtune.texi
@@ -66,6 +66,8 @@ particular CPU name.  Permissible values for this option are:
 
 @samp{arc-v-rhx-100-series},
 
+@samp{arc-v-rpx-100-series},
+
 @samp{generic-ooo},
 
 @samp{size},
diff --git a/gcc/testsuite/gcc.target/riscv/arcv-sched-mul-mem-rpx100.c 
b/gcc/testsuite/gcc.target/riscv/arcv-sched-mul-mem-rpx100.c
new file mode 100644
index 000000000000..d6e5dfadd3dc
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/arcv-sched-mul-mem-rpx100.c
@@ -0,0 +1,80 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target rv64 } */
+/* { dg-skip-if "" { *-*-* } { "-O0" "-O1" "-Oz" "-Os" } } */
+/* { dg-options "-mtune=arc-v-rpx-100-series -march=rv64imd -mabi=lp64d 
-fdump-rtl-sched2 -Wno-int-to-pointer-cast" } */
+
+void
+foo (int *a)
+{
+  a[2] = a[1] * a[0];
+
+}
+
+void foo_high(long *b) {
+  b[2] = ((__int128)b[1] * (__int128)b[0]) >> 64;
+}
+
+void foo_low(long *b) {
+  b[2] = b[1] * b[0];
+}
+
+void
+bar (int *a)
+{
+  int *addr = (int *) (a[1] * a[2]);
+  *addr = 0;
+}
+
+void
+bar_low (long *a)
+{
+  long *addr = (long *) (a[1] * a[2]);
+  *addr = 0;
+}
+
+void
+bar_high (long *a)
+{
+  long *addr = (long *) (((__int128) a[1] * (__int128) a[2]) >> 64);
+  *addr = 0;
+}
+
+int
+baz (int *a)
+{
+  int *addr = (int *) (a[1] * a[2]);
+  return *addr;
+}
+
+long
+baz_low (long *a)
+{
+  long *addr = (long *) (a[1] * a[2]);
+  return *addr;
+}
+
+long baz_high(long *a) {
+  long *addr = (long *)(((__int128) a[1] * (__int128) a[2]) >> 64);
+  return *addr;
+}
+
+/* Verify MULW to STORE data delay is 1 cycle. */
+/* { dg-final { scan-rtl-dump "(?s);; Function 
foo.*?;;\\s+1-->.*i\\s+\\d+\\s+.*\\*.*:\\(arcv.*?;;\\s+2-->.*\\\[.*0x8\\\]=" 
"sched2" } } */
+/* Verify MULW to STORE address delay is 7 cycles. */
+/* { dg-final { scan-rtl-dump "(?s);; Function 
bar.*?;;\\s+1-->.*i\\s+\\d+\\s+.*\\*.*:\\(arcv.*?;;\\s+8-->.*\\\[.*\\\]=0" 
"sched2" } } */
+/* Verify MULW to LOAD address delay is 7 cycles. */
+/* { dg-final { scan-rtl-dump "(?s);; Function 
baz.*?;;\\s+1-->.*i\\s+\\d+\\s+.*\\*.*:\\(arcv.*?;;\\s+8-->.*=.*\\\[.*\\\]" 
"sched2" } } */
+
+/* Verify MUL to STORE data delay is 1 cycle. */
+/* { dg-final { scan-rtl-dump "(?s);; Function 
foo_low.*?;;\\s+1-->.*i\\s+\\d+\\s+.*\\*.*:\\(arcv.*?;;\\s+2-->.*\\\[.*0x10\\\]="
 "sched2" } } */
+/* Verify MUL to STORE address delay is 9 cycles. */
+/* { dg-final { scan-rtl-dump "(?s);; Function 
bar_low.*?;;\\s+1-->.*i\\s+\\d+\\s+.*\\*.*:\\(arcv.*?;;\\s+10-->.*\\\[.*\\\]=0" 
"sched2" } } */
+/* Verify MUL to LOAD address delay is 9 cycles. */
+/* { dg-final { scan-rtl-dump "(?s);; Function 
baz_low.*?;;\\s+1-->.*i\\s+\\d+\\s+.*\\*.*:\\(arcv.*?;;\\s+10-->.*=.*\\\[.*\\\]"
 "sched2" } } */
+
+/* Verify MULH to STORE data delay is 1 cycle. */
+/* { dg-final { scan-rtl-dump "(?s);; Function 
foo_high.*?;;\\s+1-->.*i\\s+\\d+\\s+.*\\*.*:\\(arcv.*?;;\\s+2-->.*\\\[.*0x10\\\]="
 "sched2" } } */
+/* Verify MULH to STORE address delay is 10 cycles. */
+/* { dg-final { scan-rtl-dump "(?s);; Function 
bar_high.*?;;\\s+1-->.*i\\s+\\d+\\s+.*\\*.*:\\(arcv.*?;;\\s+11-->.*\\\[.*\\\]=0"
 "sched2" } } */
+/* Verify MULH to LOAD address delay is 10 cycles. */
+/* { dg-final { scan-rtl-dump "(?s);; Function 
baz_high.*?;;\\s+1-->.*i\\s+\\d+\\s+.*\\*.*:\\(arcv.*?;;\\s+11-->.*=.*\\\[.*\\\]"
 "sched2" } } */

Reply via email to