On 11/8/26 10:21 PM, Jim Lin wrote:
Floating-point min/max instructions currently use the "fmove" type, so a
pipeline description cannot give them a latency different from a register
move, or give fmin and fmax latencies different from each other. Add
separate "fmin" and "fmax" insn types and use them for the fmin/fmax
patterns. Every existing scheduling model that reserved "fmove" now
reserves "fmin" and "fmax" in the same way, so current scheduling does not
change.
gcc/ChangeLog:
* config/riscv/riscv.md (type): Add fmin and fmax.
(fminm<mode>3, fmin<mode>3, smin<mode>3): Use fmin type.
(fmaxm<mode>3, fmax<mode>3, smax<mode>3): Use fmax type.
* config/riscv/andes-23-series.md (andes_23_fpu_move): Add fmin
and fmax.
* 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.
---
@@ -1644,7 +1646,7 @@
(neg:ANYF (match_operand:ANYF 1 "register_operand" " f")))]
"TARGET_HARD_FLOAT || TARGET_ZFINX"
"fneg.<fmt>\t%0,%1"
- [(set_attr "type" "fmove")
+ [(set_attr "type" "fmin")
(set_attr "mode" "<UNITMODE>")])
Sashiko noted you changed the fneg pattern here, was that intentional?
;;
@@ -1661,7 +1663,7 @@
UNSPEC_FMINM))]
"TARGET_HARD_FLOAT && TARGET_ZFA"
"fminm.<fmt>\t%0,%1,%2"
- [(set_attr "type" "fmove")
+ [(set_attr "type" "fmax")
(set_attr "mode" "<UNITMODE>")])
And in this case you used the fmax type on something that was an fmin.
(define_insn "fmaxm<mode>3"
@@ -1671,7 +1673,7 @@
UNSPEC_FMAXM))]
"TARGET_HARD_FLOAT && TARGET_ZFA"
"fmaxm.<fmt>\t%0,%1,%2"
- [(set_attr "type" "fmove")
+ [(set_attr "type" "fmin")
(set_attr "mode" "<UNITMODE>")])
fmin type on an fmax insn.
(define_insn "fmin<mode>3"
@@ -1681,7 +1683,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" "fmax")
(set_attr "mode" "<UNITMODE>")])
fmax type on an fmin pattern.
(define_insn "fmax<mode>3"
@@ -1691,7 +1693,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" "fmin")
(set_attr "mode" "<UNITMODE>")])
fmin on an fmax pattern.
(define_insn "smin<mode>3"
@@ -1700,7 +1702,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" "fmax")
(set_attr "mode" "<UNITMODE>")])
fmax on an fmin pattern.
Do you really need to distinguish between min/max? If so, fine. If
not, we should just use somethign like fminmax to stand for either form.
Anyway, there's obviously still some things to fix in this patch.
jeff