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

RISC-V: Return implied extensions by const reference.

RISC-V implied extensions are now returned by const reference to avoid vector copies.

This change optimizes the RISC-V architecture support by returning the implied_exts from riscv_ext_info_t by const reference instead of by value. This eliminates unnecessary vector copies that were causing a 6.7% compile-time regression at -O0 by reducing overhead during option parsing.

In Details

The riscv_ext_info_t::implied_exts() method in common/config/riscv/riscv-common.cc previously returned a std::vector by value. All its callers iterate over the result and do not require ownership. This commit changes the return type to a const reference, preventing a costly vector copy that caused a 6.7% compile-time regression at -O0 during option parsing.

For Context
implied_exts
A member within the RISC-V extension information structure that holds a list of other CPU extensions that are implicitly enabled when a particular extension is selected.
const reference
A reference to an object that cannot be modified through that reference. It allows passing large objects efficiently without copying while ensuring their integrity.
-O0
A GCC optimization level that specifies no optimizations. This is often used for debugging, but can sometimes expose performance issues in non-optimized code paths.
Filed Under: risc-voptimizationcompile-timeconst reference