GCC Newspaper
JUNE 15, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
risc-v

RISC-V: Adds RVV main-loop overhead comparison in cost model

GCC now compares RISC-V RVV main-loop overhead in the cost model to favor loop elimination.

This commit introduces a RISC-V RVV-specific loop-overhead comparison in the cost model. The compiler now prefers RVV mode that eliminates the main loop. This change helps the compiler to select the most efficient vectorization strategy for RISC-V architectures, potentially improving performance.

In Details

The patch introduces estimated_loop_iters and compare_loop_overhead in riscv-vector-costs.cc. It modifies costs::better_main_loop_than_p function to compare RVV loop overhead after inside-loop cost. The intent is to influence the cost model to prefer RVV configurations that minimize or eliminate the main loop.

For Context

The cost model in a compiler estimates the execution cost of different code sequences to guide optimization decisions. This commit enhances the RISC-V cost model to account for the overhead of main loops in RVV (RISC-V Vector Extension) code. By comparing loop overhead, the compiler can make better decisions about whether to vectorize code and how to structure the vectorized loops.

Filed Under: risc-vrvvvectorizationcost modeloptimization