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

RISC-V: Fix register overlap for vs1 of vwadd[u].wv

RISC-V vector instruction `vwadd[u].wv` now correctly handles register overlap issues.

This commit fixes a register overlap issue in the RISC-V vwadd[u].wv vector instruction. The problem occurred when the vs1 operand’s effective element width (EEW) was twice that of the vs2 operand’s EEW, violating vector spec constraints. The fix applies a Wn4 constraint to the vs2 operand, preventing vs1 from falling within the vs2 register group, similar to the handling in vfwadd.wv.

In Details

This patch addresses an encoding constraint violation in the RISC-V vwadd[u].wv instruction. The issue arises when vs2 has an EEW of 2 * SEW while vs1 has an EEW of SEW, which the vector specification reserves. To resolve this, a Wn4 constraint is now applied to operand 3 (vs2) in config/riscv/vector.md, ensuring vs1 does not overlap with vs2's register group. This aligns with the fix for vfwadd.wv and follows guidance from the RISC-V ISA manual.

For Context
RISC-V
An open-standard instruction set architecture (ISA) based on Reduced Instruction Set Computer principles. GCC supports various RISC-V profiles and extensions.
vector extension
A set of instructions that operate on multiple data elements in parallel, often used for high-performance computing and signal processing. GCC's support for vector extensions allows for SIMD (Single Instruction, Multiple Data) operations.
vwadd.wv
A RISC-V vector instruction that performs a widened add operation with vector elements. The '.wv' suffix indicates a 'widening' operation where the result element width is larger than the source element width.
vwaddu.wv
Similar to vwadd.wv, but specifically for unsigned integer addition.
EEW
Effective Element Width. This is the actual width of elements processed by a vector instruction, which can be different from SEW due to widening or narrowing operations.
SEW
Standard Element Width. In the RISC-V vector extension, this defines the width of individual elements within a vector register.
vs1
The first source vector register operand for a RISC-V vector instruction.
vs2
The second source vector register operand for a RISC-V vector instruction.
Wn4 constraint
A constraint in RISC-V vector assembly that specifies a requirement for a register, often related to its EEW or its alignment within a larger register group. 'Wn4' likely refers to a constraint on a register that is 4 elements wide.
riscv-isa-manual
The official manual specifying the RISC-V instruction set architecture, including its extensions like the vector extension.
Filed Under: risc-vvectorcorrectness