GCC Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
risc-v Performance Win

Correct scalar floating-point costs for RISC-V vector operations

RISC-V vector cost calculation now correctly handles scalar floating-point operations.

The RISC-V backend’s cost model for vector operations was incorrectly applying integer costs to scalar floating-point operations due to receiving a null vectype. This commit corrects the cost calculation by properly recovering the scalar type and ensures that LMUL (vector length multiplier) adjustments are restricted to actual vector types, improving instruction selection accuracy.

In Details

The riscv-vector-costs.cc file's costs::adjust_stmt_cost and costs::add_stmt_cost functions are modified. Previously, scalar floating-point operations could incorrectly receive a null vectype leading to integer costs. This commit ensures the scalar type is recovered and that LMUL scaling is only applied to vector types.

For Context
RISC-V
An open-standard instruction set architecture based on Reduced Instruction Set Computer principles.
vector operations
Operations that perform the same calculation on multiple data elements simultaneously, leveraging SIMD (Single Instruction, Multiple Data) capabilities.
costing
In compilers, 'costing' refers to the process of assigning a numerical value (cost) to different operations or instructions to guide optimization decisions, such as instruction selection and scheduling.
LMUL
LMUL, or 'vector length multiplier', is a parameter in RISC-V vector instructions that scales the number of elements processed by the instruction beyond the base vector length.
scalar floating-point
Floating-point operations performed on single, individual values, as opposed to multiple values in a vector.
Filed Under: risc-vvectorizationoptimizationcost model