[PATCH v2] RISC-V: Add LMUL-aware RVV cost model for the Spacemit-X60 core

Nikola Ratkovac Nikola.Ratkovac@rt-rk.com
Fri Feb 13 18:13:49 GMT 2026


This patch introduces a vector cost model for the Spacemit-X60 core,
using dynamic LMUL scaling with the -madjust-lmul-cost flag.

Compared to the previous patch, I dropped the local 'vector_lmul'
attribute and the corresponding LMUL-aware cost logic in spacemit-x60.md.
Instead, Spacemit-X60 tuning now enables -madjust-lmul-cost implicitly,
and riscv_sched_adjust_cost is updated so that the adjustment applies to
spacemit_x60 in addition to the generic out-of-order model.

The stress tests I previously used to tune individual instruction costs
(with the LMUL-aware logic implemented directly in spacemit-x60.md)
now show a regression in performance. The most likely cause is the implicit
-madjust-lmul-cost scaling, since some instructions performed better
with non-power-of-two scaling (or with no LMUL scaling at all), so the
uniform ×(1,2,4,8) adjustment affects performance.

Updated performance results:

| Benchmark        | Metric | Trunk            | Vector Cost Model | Δ (%)   |
|------------------|--------|------------------|-------------------|---------|
| SciMark2-C       | cycles | 311,450,555,453  | 313,278,899,107   | +0.56%  |
|------------------|--------|------------------|-------------------|---------|
| tramp3d-v4       | cycles | 23,788,980,247   | 21,073,526,428    | -12.89% |
|------------------|--------|------------------|-------------------|---------|
| Freebench/neural | cycles | 471,707,641      | 435,842,612       | -8.23%  |
|------------------|--------|------------------|-------------------|---------|

Benchmarks were run from the LLVM test-suite
(MultiSource/Benchmarks) using:

taskset -c 0 perf stat -r 10 ./...

SciMark2-C (ANSI C), FreeBench/neural, and tramp3d-v4
were used as representative numerical workloads.

For tramp3d-v4, the workload parameters (--cartvis 1.0 0.0, --rhomin 1e-8,
-n 20) increase floating-point intensity and dependency pressure, placing
greater stress on the scheduler.

2026-02-13  Nikola Ratkovac  <Nikola.Ratkovac@rt-rk.com>

gcc/ChangeLog:

        * config/riscv/spacemit-x60.md: Add primary vector pipeline model
        for Spacemit-X60.
        (spacemit_x60_dummy): Rename from spacemi6_x60_dummy.
        * config/riscv/riscv.cc (riscv_sched_adjust_cost): Support spacemit_x60.
        (riscv_override_options_internal): Enable TARGET_ADJUST_LMUL_COST
        for spacemit_x60.



CONFIDENTIALITY: The contents of this e-mail are confidential and intended only for the above addressee(s). If you are not the intended recipient, or the person responsible for delivering it to the intended recipient, copying or delivering it to anyone else or using it in any unauthorized manner is prohibited and may be unlawful. If you receive this e-mail by mistake, please notify the sender and the systems administrator at straymail@rt-rk.com immediately.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: Vector-Cost-Model.patch.txt
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20260213/21349803/attachment-0001.txt>


More information about the Gcc-patches mailing list