GCC Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
target/riscv Performance Win

RISC-V vector cost model includes scalar loads/stores.

RISC-V vector cost model now accounts for scalar loads/stores to avoid ratio mismatches.

The cost model for RISC-V vector operations has been updated to include scalar loads and stores in the LMUL ratio calculation. Previously, gathers and scatters were costed as scalar operations but not factored into the LMUL ratio, leading to potential mismatches when comparing different loops.

This change ensures that the vector cost model accurately reflects the performance implications of scalar operations within vector contexts, improving loop optimization decisions.

In Details

In config/riscv/riscv-vector-costs.cc, the costs::record_type_sizes function is responsible for assigning costs to various data types and operations for the RISC-V vector extension. The LMUL (Lane Multiplication) ratio is a key factor in vector instruction cost and scheduling. This commit adds scalar_load and scalar_store to the types recorded by this function. This ensures that when these operations are used, for example, within gather/scatter instructions which are costed as scalar loads/stores, they are correctly considered in the overall LMUL ratio calculation, preventing inaccura…

For Context
RISC-V
An open-standard instruction set architecture (ISA) based on Reduced Instruction Set Computing principles. It is modular and extensible, with specific extensions for vector processing.
LMUL ratio
Lane Multiplication ratio. In RISC-V vector instructions, LMUL determines how many elements a single vector instruction operates on. A higher LMUL means more elements are processed per cycle, impacting instruction cost and throughput.
Vector loads/stores
Instructions that load or store multiple data elements from or to memory in a single operation, utilizing vector registers.
Gathers and scatters
Specialized vector memory operations where the addresses of the elements to be accessed are specified in a separate vector register (gather) or written to memory (scatter). These are often implemented using scalar load/store mechanisms at a lower level.
Filed Under: RISC-Vvectorizationoptimizationcost model