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

commit r17-6510-gf7c5b126b8564cb63c9c106e763036453c1add37
Author: Jim Lin <[email protected]>
Date:   Fri Nov 20 16:31:54 2026 -0700

    [PATCH 1/1] RISC-V: Add fminmax insn type
    
    Floating-point min/max instructions currently use the "fmove" type, so a
    pipeline description cannot give them a latency different from a register
    move.  Add a separate "fminmax" insn type and use it for the fmin/fmax
    patterns.  Every existing scheduling model that reserved "fmove" now
    reserves "fminmax" in the same way, so current scheduling does not change.
    
    gcc/ChangeLog:
    
            * config/riscv/riscv.md (type): Add fminmax.
            (fminm<mode>3, fmaxm<mode>3, fmin<mode>3, fmax<mode>3)
            (smin<mode>3, smax<mode>3): Use fminmax type.
            * config/riscv/andes-23-series.md (andes_23_fpu_move): Add fminmax.
            * config/riscv/andes-25-series.md (andes_25_fpu_move): Likewise.
            * config/riscv/andes-45-series.md (andes_45_fpu_move): Likewise.
            * config/riscv/arcv-rhx100.md (arcv_rhx100_xfer): Likewise.
            * config/riscv/arcv-rmx100.md (arcv_rmx100_xfer): Likewise.
            * config/riscv/generic-ooo.md (generic_ooo_float_move): Likewise.
            * config/riscv/generic.md (generic_xfer): Likewise.
            * config/riscv/mips-p8700.md (mips_p8700_fpu_fabs): Likewise.
            * config/riscv/sifive-7.md (sifive_7_fp_other): Likewise.
            * config/riscv/sifive-p400.md (sifive_p400_fmove): Likewise.
            * config/riscv/sifive-p600.md (sifive_p600_fmove): Likewise.
            * config/riscv/spacemit-x60.md (spacemit_x60_fcvt): Likewise.
            * config/riscv/tt-ascalon-d8.md (tt_ascalon_d8_float_move): 
Likewise.
            * config/riscv/xiangshan.md (xiangshan_f2f): Likewise.
            * config/riscv/xt-c908.md (xt_c908_fcvt): Likewise.
            * config/riscv/mips-i8500.md: Split out fminmax to its own 2c 
reservation.
            Change basic move reservation to 1c.
    
    Co-authored-by: Jeff Law  <[email protected]>

Diff:
---
 gcc/config/riscv/andes-23-series.md |  2 +-
 gcc/config/riscv/andes-25-series.md |  2 +-
 gcc/config/riscv/andes-45-series.md |  2 +-
 gcc/config/riscv/arcv-rhx100.md     |  2 +-
 gcc/config/riscv/arcv-rmx100.md     |  2 +-
 gcc/config/riscv/generic-ooo.md     |  2 +-
 gcc/config/riscv/generic.md         |  2 +-
 gcc/config/riscv/mips-i8500.md      | 10 ++++++----
 gcc/config/riscv/mips-p8700.md      |  2 +-
 gcc/config/riscv/riscv.md           | 19 ++++++++++---------
 gcc/config/riscv/sifive-7.md        |  2 +-
 gcc/config/riscv/sifive-p400.md     |  2 +-
 gcc/config/riscv/sifive-p600.md     |  2 +-
 gcc/config/riscv/spacemit-x60.md    |  2 +-
 gcc/config/riscv/tt-ascalon-d8.md   |  2 +-
 gcc/config/riscv/xiangshan.md       |  2 +-
 gcc/config/riscv/xt-c908.md         |  2 +-
 17 files changed, 31 insertions(+), 28 deletions(-)

diff --git a/gcc/config/riscv/andes-23-series.md 
b/gcc/config/riscv/andes-23-series.md
index 70b4da3435c7..edbc61c3369e 100644
--- a/gcc/config/riscv/andes-23-series.md
+++ b/gcc/config/riscv/andes-23-series.md
@@ -112,7 +112,7 @@
 
 (define_insn_reservation "andes_23_fpu_move" 2
   (and (eq_attr "tune" "andes_23_series")
-       (eq_attr "type" "fmove,mtc,mfc"))
+       (eq_attr "type" "fmove,fminmax,mtc,mfc"))
   "andes_23_pipe_unify, andes_23_fpu")
 
 (define_insn_reservation "andes_23_fpu_cmp" 3
diff --git a/gcc/config/riscv/andes-25-series.md 
b/gcc/config/riscv/andes-25-series.md
index c9e9c5e7c552..c2fc367b1411 100644
--- a/gcc/config/riscv/andes-25-series.md
+++ b/gcc/config/riscv/andes-25-series.md
@@ -128,7 +128,7 @@
 
 (define_insn_reservation "andes_25_fpu_move" 3
   (and (eq_attr "tune" "andes_25_series")
-       (eq_attr "type" "fmove,mtc,mfc"))
+       (eq_attr "type" "fmove,fminmax,mtc,mfc"))
   "andes_25_fpu_pipe")
 
 (define_insn_reservation "andes_25_fpu_cmp" 3
diff --git a/gcc/config/riscv/andes-45-series.md 
b/gcc/config/riscv/andes-45-series.md
index c4d02b8c5392..34729d778eb6 100644
--- a/gcc/config/riscv/andes-45-series.md
+++ b/gcc/config/riscv/andes-45-series.md
@@ -157,7 +157,7 @@
 
 (define_insn_reservation "andes_45_fpu_move" 1
   (and (eq_attr "tune" "andes_45_series")
-       (eq_attr "type" "fmove,mtc,mfc"))
+       (eq_attr "type" "fmove,fminmax,mtc,mfc"))
   "andes_45_pipe0 + andes_45_fpu_fmv | andes_45_pipe1 + andes_45_fpu_fmv")
 
 (define_insn_reservation "andes_45_fpu_cmp" 2
diff --git a/gcc/config/riscv/arcv-rhx100.md b/gcc/config/riscv/arcv-rhx100.md
index a0340ceb0df1..5c8a9d58ba5c 100644
--- a/gcc/config/riscv/arcv-rhx100.md
+++ b/gcc/config/riscv/arcv-rhx100.md
@@ -87,7 +87,7 @@
 ;; (soft) floating points
 (define_insn_reservation "arcv_rhx100_xfer" 3
   (and (eq_attr "tune" "arcv_rhx100,arcv_rpx100")
-       (eq_attr "type" "mfc,mtc,fcvt,fcvt_i2f,fcvt_f2i,fmove,fcmp"))
+       (eq_attr "type" "mfc,mtc,fcvt,fcvt_i2f,fcvt_f2i,fmove,fminmax,fcmp"))
   "(arcv_rhx100_ALU_A_fuse0_early | arcv_rhx100_ALU_B_fuse0_early)")
 
 (define_insn_reservation "arcv_rhx100_fmul" 5
diff --git a/gcc/config/riscv/arcv-rmx100.md b/gcc/config/riscv/arcv-rmx100.md
index e2152f38eb95..f8034769d5fd 100644
--- a/gcc/config/riscv/arcv-rmx100.md
+++ b/gcc/config/riscv/arcv-rmx100.md
@@ -70,7 +70,7 @@
 
 (define_insn_reservation "arcv_rmx100_xfer" 1
   (and (eq_attr "tune" "arcv_rmx100")
-       (eq_attr "type" "fmove,mtc,mfc,fcvt,fcvt_f2i,fcvt_i2f"))
+       (eq_attr "type" "fmove,fminmax,mtc,mfc,fcvt,fcvt_f2i,fcvt_i2f"))
    "arcv_rmx100_FPU")
 
 (define_insn_reservation "arcv_rmx100_fmul_insn" 2
diff --git a/gcc/config/riscv/generic-ooo.md b/gcc/config/riscv/generic-ooo.md
index 7ff05b7accfa..f4607d276385 100644
--- a/gcc/config/riscv/generic-ooo.md
+++ b/gcc/config/riscv/generic-ooo.md
@@ -105,7 +105,7 @@
 ;; Float move, convert and compare.
 (define_insn_reservation "generic_ooo_float_move" 3
   (and (eq_attr "tune" "generic_ooo")
-       (eq_attr "type" "fmove"))
+       (eq_attr "type" "fmove,fminmax"))
   "generic_ooo_issue,generic_ooo_fxu")
 
 (define_insn_reservation "generic_ooo_fcvt" 3
diff --git a/gcc/config/riscv/generic.md b/gcc/config/riscv/generic.md
index e286bc7f9c30..78d4b933e1da 100644
--- a/gcc/config/riscv/generic.md
+++ b/gcc/config/riscv/generic.md
@@ -44,7 +44,7 @@
 
 (define_insn_reservation "generic_xfer" 3
   (and (eq_attr "tune" "generic")
-       (eq_attr "type" "mfc,mtc,fcvt,fcvt_i2f,fcvt_f2i,fmove,fcmp"))
+       (eq_attr "type" "mfc,mtc,fcvt,fcvt_i2f,fcvt_f2i,fmove,fminmax,fcmp"))
   "alu")
 
 (define_insn_reservation "generic_branch" 1
diff --git a/gcc/config/riscv/mips-i8500.md b/gcc/config/riscv/mips-i8500.md
index dc74ddad7f2a..2999d4430df1 100644
--- a/gcc/config/riscv/mips-i8500.md
+++ b/gcc/config/riscv/mips-i8500.md
@@ -89,14 +89,16 @@
        (eq_attr "type" "mfc,mtc"))
   "mips_i8500_control_alu0 | mips_i8500_agen_alu1")
 
-;; fmin/fmax takes 2 cycles where as remaining fmove instructions such as
-;; fabs, fsgnj, fmv.w.x takes 1 cycle.  so define the latency for fmove as
-;; 2 (worstcase)
-(define_insn_reservation "mips_i8500_fmove" 2
+(define_insn_reservation "mips_i8500_fmove" 1
   (and (eq_attr "tune" "mips_i8500")
        (eq_attr "type" "fmove"))
   "mips_i8500_fpu_short")
 
+(define_insn_reservation "mips_i8500_fminmax" 2
+  (and (eq_attr "tune" "mips_i8500")
+       (eq_attr "type" "fminmax"))
+  "mips_i8500_fpu_short")
+
 (define_insn_reservation "mips_i8500_fcmp" 2
   (and (eq_attr "tune" "mips_i8500")
        (eq_attr "type" "fcmp"))
diff --git a/gcc/config/riscv/mips-p8700.md b/gcc/config/riscv/mips-p8700.md
index e1b5f53ee127..728b5a6769b7 100644
--- a/gcc/config/riscv/mips-p8700.md
+++ b/gcc/config/riscv/mips-p8700.md
@@ -56,7 +56,7 @@
 
 (define_insn_reservation "mips_p8700_fpu_fabs" 2
   (and (eq_attr "tune" "mips_p8700")
-       (eq_attr "type" "fcmp,fmove"))
+       (eq_attr "type" "fcmp,fmove,fminmax"))
   "mips_p8700_fpu_short, mips_p8700_fpu_apu")
 
 (define_insn_reservation "mips_p8700_fpu_fload" 8
diff --git a/gcc/config/riscv/riscv.md b/gcc/config/riscv/riscv.md
index 25e5001e9602..f45d003e1f76 100644
--- a/gcc/config/riscv/riscv.md
+++ b/gcc/config/riscv/riscv.md
@@ -332,6 +332,7 @@
 ;; idiv                integer divide
 ;; move                integer register move (addi rd, rs1, 0)
 ;; fmove       floating point register move
+;; fminmax     floating point min/max
 ;; fadd                floating point add/subtract
 ;; fmul                floating point multiply
 ;; fmadd       floating point multiply-add
@@ -508,9 +509,9 @@
 ;; xt_vilo      vector odd interleave instruction
 (define_attr "type"
   "unknown,branch,jump,jalr,ret,call,load,fpload,store,fpstore,
-   mtc,mfc,const,arith,logical,shift,slt,imul,idiv,move,fmove,fadd,fmul,
-   fmadd,fdiv,fcmp,fcvt,fcvt_i2f,fcvt_f2i,fsqrt,multi,auipc,sfb_alu,nop,trap,
-   ghost,bitmanip,rotate,clmul,min,max,minu,maxu,clz,ctz,cpop,
+   mtc,mfc,const,arith,logical,shift,slt,imul,idiv,move,fmove,fminmax,
+   fadd,fmul,fmadd,fdiv,fcmp,fcvt,fcvt_i2f,fcvt_f2i,fsqrt,multi,auipc,sfb_alu,
+   nop,trap,ghost,bitmanip,rotate,clmul,min,max,minu,maxu,clz,ctz,cpop,
    atomic,condmove,crypto,mvpair,zicond,rdvlenb,rdvl,wrvxrm,wrfrm,
    rdfrm,vsetvl,vsetvl_pre,vlde,vste,vldm,vstm,vlds,vsts,
    vldux,vldox,vstux,vstox,vldff,vldr,vstr,
@@ -1667,7 +1668,7 @@
                     UNSPEC_FMINM))]
   "TARGET_HARD_FLOAT && TARGET_ZFA"
   "fminm.<fmt>\t%0,%1,%2"
-  [(set_attr "type" "fmove")
+  [(set_attr "type" "fminmax")
    (set_attr "mode" "<UNITMODE>")])
 
 (define_insn "fmaxm<mode>3"
@@ -1677,7 +1678,7 @@
                     UNSPEC_FMAXM))]
   "TARGET_HARD_FLOAT && TARGET_ZFA"
   "fmaxm.<fmt>\t%0,%1,%2"
-  [(set_attr "type" "fmove")
+  [(set_attr "type" "fminmax")
    (set_attr "mode" "<UNITMODE>")])
 
 (define_insn "fmin<mode>3"
@@ -1687,7 +1688,7 @@
                     UNSPEC_FMIN))]
   "(TARGET_HARD_FLOAT || TARGET_ZFINX) && !HONOR_SNANS (<MODE>mode)"
   "fmin.<fmt>\t%0,%1,%2"
-  [(set_attr "type" "fmove")
+  [(set_attr "type" "fminmax")
    (set_attr "mode" "<UNITMODE>")])
 
 (define_insn "fmax<mode>3"
@@ -1697,7 +1698,7 @@
                     UNSPEC_FMAX))]
   "(TARGET_HARD_FLOAT || TARGET_ZFINX) && !HONOR_SNANS (<MODE>mode)"
   "fmax.<fmt>\t%0,%1,%2"
-  [(set_attr "type" "fmove")
+  [(set_attr "type" "fminmax")
    (set_attr "mode" "<UNITMODE>")])
 
 (define_insn "smin<mode>3"
@@ -1706,7 +1707,7 @@
                   (match_operand:ANYF 2 "register_operand" " f")))]
   "TARGET_HARD_FLOAT || TARGET_ZFINX"
   "fmin.<fmt>\t%0,%1,%2"
-  [(set_attr "type" "fmove")
+  [(set_attr "type" "fminmax")
    (set_attr "mode" "<UNITMODE>")])
 
 (define_insn "smax<mode>3"
@@ -1715,7 +1716,7 @@
                   (match_operand:ANYF 2 "register_operand" " f")))]
   "TARGET_HARD_FLOAT || TARGET_ZFINX"
   "fmax.<fmt>\t%0,%1,%2"
-  [(set_attr "type" "fmove")
+  [(set_attr "type" "fminmax")
    (set_attr "mode" "<UNITMODE>")])
 
 ;;
diff --git a/gcc/config/riscv/sifive-7.md b/gcc/config/riscv/sifive-7.md
index 94dcb9355b8d..84b4f1c0f764 100644
--- a/gcc/config/riscv/sifive-7.md
+++ b/gcc/config/riscv/sifive-7.md
@@ -101,7 +101,7 @@
 
 (define_insn_reservation "sifive_7_fp_other" 3
   (and (eq_attr "tune" "sifive_7")
-       (eq_attr "type" "fcvt,fcvt_i2f,fcvt_f2i,fcmp,fmove"))
+       (eq_attr "type" "fcvt,fcvt_i2f,fcvt_f2i,fcmp,fmove,fminmax"))
   "sifive_7_B")
 
 (define_insn_reservation "sifive_7_fdiv_h" 14
diff --git a/gcc/config/riscv/sifive-p400.md b/gcc/config/riscv/sifive-p400.md
index 9a19f0a4b314..49f627b6da19 100644
--- a/gcc/config/riscv/sifive-p400.md
+++ b/gcc/config/riscv/sifive-p400.md
@@ -150,7 +150,7 @@
 
 (define_insn_reservation "sifive_p400_fmove" 2
   (and (eq_attr "tune" "sifive_p400")
-       (eq_attr "type" "fmove,fcvt"))
+       (eq_attr "type" "fmove,fminmax,fcvt"))
   "p400_float_pipe,sifive_p400_fpu")
 
 ;; We need something for HF so that we don't abort during
diff --git a/gcc/config/riscv/sifive-p600.md b/gcc/config/riscv/sifive-p600.md
index e845b4e75bfc..b748e5c68291 100644
--- a/gcc/config/riscv/sifive-p600.md
+++ b/gcc/config/riscv/sifive-p600.md
@@ -154,7 +154,7 @@
 
 (define_insn_reservation "sifive_p600_fmove" 2
   (and (eq_attr "tune" "sifive_p600")
-       (eq_attr "type" "fmove,fcvt"))
+       (eq_attr "type" "fmove,fminmax,fcvt"))
   "float_pipe,sifive_p600_fpu")
 
 ;; We need something for HF so that we don't abort during
diff --git a/gcc/config/riscv/spacemit-x60.md b/gcc/config/riscv/spacemit-x60.md
index e96f6b863c6a..6c0a9f82cc95 100644
--- a/gcc/config/riscv/spacemit-x60.md
+++ b/gcc/config/riscv/spacemit-x60.md
@@ -130,7 +130,7 @@
 
 (define_insn_reservation "spacemit_x60_fcvt" 4
   (and (eq_attr "tune" "spacemit_x60")
-       (eq_attr "type" "fcvt,fmove"))
+       (eq_attr "type" "fcvt,fmove,fminmax"))
   "spacemit_x60_fpalu")
 
 (define_insn_reservation "spacemit_x60_fcmp" 6
diff --git a/gcc/config/riscv/tt-ascalon-d8.md 
b/gcc/config/riscv/tt-ascalon-d8.md
index 5ea0e46abd51..43bf2eadde3b 100644
--- a/gcc/config/riscv/tt-ascalon-d8.md
+++ b/gcc/config/riscv/tt-ascalon-d8.md
@@ -75,7 +75,7 @@
 ;; are executed by the FPU, but we can't model that at the moment.
 (define_insn_reservation "tt_ascalon_d8_float_move" 4
   (and (eq_attr "tune" "tt_ascalon_d8,tt_ascalon_xg")
-       (eq_attr "type" "fmove"))
+       (eq_attr "type" "fmove,fminmax"))
   "tt_ascalon_d8_decode,tt_ascalon_d8_fp")
 
 (define_insn_reservation "tt_ascalon_d8_fcvt" 3
diff --git a/gcc/config/riscv/xiangshan.md b/gcc/config/riscv/xiangshan.md
index de2f46ef679e..e37a6a104b87 100644
--- a/gcc/config/riscv/xiangshan.md
+++ b/gcc/config/riscv/xiangshan.md
@@ -157,7 +157,7 @@
 
 (define_insn_reservation "xiangshan_f2f" 3
   (and (eq_attr "tune" "xiangshan")
-       (eq_attr "type" "fcvt,fcvt_f2i,fmove"))
+       (eq_attr "type" "fcvt,fcvt_f2i,fmove,fminmax"))
   "xs_fmisc_rs")
 
 (define_insn_reservation "xiangshan_f2i" 3
diff --git a/gcc/config/riscv/xt-c908.md b/gcc/config/riscv/xt-c908.md
index 0456f3f81d83..827eb94908a6 100644
--- a/gcc/config/riscv/xt-c908.md
+++ b/gcc/config/riscv/xt-c908.md
@@ -69,7 +69,7 @@
 
 (define_insn_reservation "xt_c908_fcvt" 4
   (and (eq_attr "tune" "xt_c908")
-       (eq_attr "type" "fcvt,fmove,fcvt_i2f,fcvt_f2i"))
+       (eq_attr "type" "fcvt,fmove,fminmax,fcvt_i2f,fcvt_f2i"))
   "xt_c908_fpalu")
 
 (define_insn_reservation "xt_c908_fcmp" 4

Reply via email to