]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[RISC-V][PR target/121113] Handle HFmode in various insn reservations
authorJeff Law <jlaw@ventanamicro.com>
Wed, 13 Aug 2025 02:29:50 +0000 (20:29 -0600)
committerJeff Law <jlaw@ventanamicro.com>
Wed, 13 Aug 2025 02:31:34 +0000 (20:31 -0600)
So this is a minor bug in a few DFA descriptions such as the Xiangshan and a
couple of the SiFive descriptions.

While Xiangshan covers every insn type, some of the reservations check the mode
of the operation.   Concretely the fdiv/fsqrt unit reservations vary based on
the mode.  They handled DF/SF, but not HF (the relevant iterators don't include
BF).

This patch just adds HF support with the same characteristics as SF. Those who
know these designs better could perhaps improve the reservation, but this at
least keeps us from aborting.

I did check the other published DFAs for mode dependent reservations. That's
show I found the p400/p600 issue.

Tested in my tester, waiting for CI to render its verdict before pushing.

PR target/121113
gcc/
* config/riscv/sifive-p400.md: Handle HFmode for fdiv/fsqrt.
* config/riscv/sifive-p600.md: Likewise.
* config/riscv/xiangshan.md: Likewise.

gcc/testsuite/
* gcc.target/riscv/pr121113.c: New test.

gcc/config/riscv/sifive-p400.md
gcc/config/riscv/sifive-p600.md
gcc/config/riscv/xiangshan.md
gcc/testsuite/gcc.target/riscv/pr121113.c [new file with mode: 0644]

index ed8b8ec9da7b761107c9ca922636f8eb4bc22478..d6f6e2a3b6c0156f2ebc693283ee9a73348192c1 100644 (file)
        (eq_attr "type" "fmove,fcvt"))
   "p400_float_pipe,sifive_p400_fpu")
 
+;; We need something for HF so that we don't abort during
+;; scheduling if someone was to ask for p400 scheduling, but
+;; enable the various HF mode extensions.
 (define_insn_reservation "sifive_p400_fdiv_s" 18
   (and (eq_attr "tune" "sifive_p400")
        (eq_attr "type" "fdiv,fsqrt")
-       (eq_attr "mode" "SF"))
+       (eq_attr "mode" "HF,SF"))
   "sifive_p400_FM, sifive_p400_fdiv*5")
 
 (define_insn_reservation "sifive_p400_fdiv_d" 31
index 240134976fa1ee01b5d4b569de242b094f8500e9..ff51149f9b70364ac7c8e2e43b9fc7eb3211eac3 100644 (file)
        (eq_attr "type" "fmove,fcvt"))
   "float_pipe,sifive_p600_fpu")
 
+;; We need something for HF so that we don't abort during
+;; scheduling if someone was to ask for p600 scheduling, but
+;; enable the various HF mode extensions.
 (define_insn_reservation "sifive_p600_fdiv_s" 11
   (and (eq_attr "tune" "sifive_p600")
        (eq_attr "type" "fdiv,fsqrt")
-       (eq_attr "mode" "SF"))
+       (eq_attr "mode" "HF,SF"))
   "sifive_p600_FM, sifive_p600_fdiv*5")
 
 (define_insn_reservation "sifive_p600_fdiv_d" 19
index 34b4a8f1f3fc96bec4f5ec7a7d7e45225bc3b28a..61791408781514d952db6b9876b2e8fe3b21578b 100644 (file)
 (define_insn_reservation "xiangshan_sfdiv" 11
   (and (eq_attr "tune" "xiangshan")
        (eq_attr "type" "fdiv")
-       (eq_attr "mode" "SF"))
+       (eq_attr "mode" "HF,SF"))
   "xs_fmisc_rs")
 
 (define_insn_reservation "xiangshan_sfsqrt" 17
   (and (eq_attr "tune" "xiangshan")
        (eq_attr "type" "fsqrt")
-       (eq_attr "mode" "SF"))
+       (eq_attr "mode" "HF,SF"))
   "xs_fmisc_rs")
 
 (define_insn_reservation "xiangshan_dfdiv" 21
diff --git a/gcc/testsuite/gcc.target/riscv/pr121113.c b/gcc/testsuite/gcc.target/riscv/pr121113.c
new file mode 100644 (file)
index 0000000..091fa82
--- /dev/null
@@ -0,0 +1,5 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-std=c23 -mcpu=xiangshan-kunminghu" } */
+
+_Float16 f, g;
+void foo() { f /= g; }