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

Optimize whole-register moves by reusing legal VTYPE.

RISC-V vector extension: improves handling of whole-register moves.

This commit optimizes the handling of whole-register moves in the RISC-V Vector extension. Previously, the vsetvl pass could unnecessarily insert vsetivli instructions before and after moves, even when a suitable register configuration was already available. This change allows whole-register moves to be represented as demands that are satisfied by any legal VTYPE configuration, rather than requiring specific SEW, LMUL, or VL constraints. This avoids redundant vsetvl operations and simplifies the instruction sequence for these moves.

In Details

For RISC-V vector whole-register moves (where vill is clear but other VTYPE fields and VL are irrelevant), the vsetvl pass's current logic of deriving policy requirements from the RTL mode can lead to suboptimal vsetivli insertions. This patch refactors vsetvl_info::parse_insn to assign an unconstrained legal_vtype demand for such moves. New rules in riscv-vsetvl.def and modifications to vsetvl_info::normalize_demand and pre_vsetvl::preds_all_same_avl_and_ratio_p ensure that these moves are treated as valid demands that can be met by existing legal configurations, preventing u…

For Context
RISC-V Vector Extension (RVV)
An extension to the RISC-V instruction set architecture designed for high-performance vector processing.
VTYPE
A configuration register in the RISC-V Vector extension that defines parameters like element width (SEW) and lane multiplication (LMUL).
vsetvl
A RISC-V vector instruction used to set the vector length (VL) and vector type (VTYPE) for subsequent vector operations.
SEW
Shorthand for 'Standard Element Width', defining the bit width of individual elements within a vector register.
LMUL
Lane Multiplier, a factor that determines how many vector elements are processed in parallel within a vector register.
AVL
Actual Vector Length, used when the total data length is not a multiple of the vector length.
Filed Under: risc-vvector extensionoptimizationinstruction selection