RISC-V: Allow register overlap for vfwsub.wv instruction
RISC-V vector extension now allows register overlap for vfwsub.wv, improving code generation flexibility.
The RISC-V Vector extension’s vfwsub.wv instruction now supports register overlap, similar to vfwadd.wv. This change allows the source operand vs1 to overlap with the destination register vd under specific conditions, while still preventing overlap with vs2’s register group. This modification enhances the compiler’s ability to generate efficient code by providing more flexibility in register allocation.
In Details
This commit updates the RISC-V vector instruction pattern matching in config/riscv/vector.md to permit register overlap for vfwsub.wv. It introduces Wn4 and Wvr constraints for operands 3 and 4, respectively, to enable the 2 * SEW = 2 * SEW - SEW form. This allows vs1 to overlap with the higher part of vd, provided it does not overlap with vs2's register group, enhancing code generation efficiency for subword vector operations.
- vfwsub.wv
- A RISC-V Vector extension instruction for performing floating-point subword operations with register-based width and vector destination. It takes two source registers (vs1, vs2) and writes to a destination register (vd).
- SEW
- Standard Element Width, a parameter in RISC-V Vector extension that defines the bit-width of individual elements within a vector register.
- vs1, vs2, vd
- Source vector register 1, Source vector register 2, and Vector Destination register, respectively, used in RISC-V Vector extension instructions.
- Register overlap
- A condition where a source or destination register in an instruction can be the same as, or partially overlap with, another register involved in the same instruction. This can improve code density and performance by reducing the need for temporary registers.