https://gcc.gnu.org/g:357b4a26b693fa7b6e6ff8f6609184341737a1f3

commit r17-6434-g357b4a26b693fa7b6e6ff8f6609184341737a1f3
Author: Pan Li <[email protected]>
Date:   Thu Nov 12 16:31:11 2026 +0800

    RISC-V: Fix reg overlap for vs1 of vwsub[u].wv
    
    The vs2 of the vwsub[u].wv is read with EEW = 2 * SEW while the vs1
    is read with EEW = SEW.  The section 5.2 of the vector spec reserves
    any encoding in which one vector register supplies source operands
    with two or more different EEWs.  Thus, the vs1 must not fall inside
    the vs2 register group, but we may have below asm dump when the vs1
    comes from the vs2 register group.
    
      vwsub.wv v6,v2,v2
    
    Like the vfwsub.wv, take the Wn4 constraint for the operand 3 (aka vs2)
    of the vwsub[u].wv.  See below issue of the riscv-isa-manual for more
    details.
    
      https://github.com/riscv/riscv-isa-manual/issues/2350
    
    gcc/ChangeLog:
    
            * config/riscv/vector.md: Take the Wn4 constraint for the
            operand 3 of the vwsub[u].wv.
    
    Signed-off-by: Pan Li <[email protected]>

Diff:
---
 gcc/config/riscv/vector.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/config/riscv/vector.md b/gcc/config/riscv/vector.md
index ed16e7d20a9a..5413bedcb3f3 100644
--- a/gcc/config/riscv/vector.md
+++ b/gcc/config/riscv/vector.md
@@ -4231,7 +4231,7 @@
             (reg:SI VL_REGNUM)
             (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
          (minus:VWEXTI
-           (match_operand:VWEXTI 3 "register_operand"             " vr, vr, 
vr, vr")
+           (match_operand:VWEXTI 3 "register_operand"             
"Wn4,Wn4,Wn4,Wn4")
            (any_extend:VWEXTI
              (match_operand:<V_DOUBLE_TRUNC> 4 "register_operand" 
"Wvr,Wvr,Wvr,Wvr")))
          (match_operand:VWEXTI 2 "vector_merge_operand"           " vu,  0, 
vu,  0")))]

Reply via email to