https://gcc.gnu.org/g:759916c4bd250d5a96320e06cdafa5a16e9ea38f

commit r17-6135-g759916c4bd250d5a96320e06cdafa5a16e9ea38f
Author: Pan Li <[email protected]>
Date:   Fri Nov 6 10:39:51 2026 +0800

    RISC-V: Add test cases for vwadd.wv vs1 reg overlap
    
    Add test cases to ensure the vs1 of the vwadd.wv doesn't overlap
    the register group of the vs2.
    
    gcc/testsuite/ChangeLog:
    
            * gcc.target/riscv/rvv/autovec/group_overlap/group_overlap.h
            (LOOP_WIDEN_BINARY_WV_BODY_OVERLAP_X2): New macro for the vs1
            comes from the vs2 register group.
            (DEF_GROUP_OVERLAP_BINARY_4): New macro.
            * gcc.target/riscv/rvv/autovec/group_overlap/vwadd_wv_vs1-i8-m1.c: 
New test.
            * gcc.target/riscv/rvv/autovec/group_overlap/vwadd_wv_vs1-i8-m2.c: 
New test.
            * gcc.target/riscv/rvv/autovec/group_overlap/vwadd_wv_vs1-i8-m4.c: 
New test.
            * gcc.target/riscv/rvv/autovec/group_overlap/vwadd_wv_vs1-i8-mf2.c: 
New test.
            * gcc.target/riscv/rvv/autovec/group_overlap/vwadd_wv_vs1-i8-mf4.c: 
New test.
            * gcc.target/riscv/rvv/autovec/group_overlap/vwadd_wv_vs1-i8-mf8.c: 
New test.
            * gcc.target/riscv/rvv/autovec/group_overlap/vwadd_wv_vs1-i16-m1.c: 
New test.
            * gcc.target/riscv/rvv/autovec/group_overlap/vwadd_wv_vs1-i16-m2.c: 
New test.
            * gcc.target/riscv/rvv/autovec/group_overlap/vwadd_wv_vs1-i16-m4.c: 
New test.
            * 
gcc.target/riscv/rvv/autovec/group_overlap/vwadd_wv_vs1-i16-mf2.c: New test.
            * 
gcc.target/riscv/rvv/autovec/group_overlap/vwadd_wv_vs1-i16-mf4.c: New test.
            * gcc.target/riscv/rvv/autovec/group_overlap/vwadd_wv_vs1-i32-m1.c: 
New test.
            * gcc.target/riscv/rvv/autovec/group_overlap/vwadd_wv_vs1-i32-m2.c: 
New test.
            * gcc.target/riscv/rvv/autovec/group_overlap/vwadd_wv_vs1-i32-m4.c: 
New test.
            * 
gcc.target/riscv/rvv/autovec/group_overlap/vwadd_wv_vs1-i32-mf2.c: New test.
    
    Signed-off-by: Pan Li <[email protected]>

Diff:
---
 .../rvv/autovec/group_overlap/group_overlap.h      | 44 ++++++++++++++++++++++
 .../autovec/group_overlap/vwadd_wv_vs1-i16-m1.c    | 38 +++++++++++++++++++
 .../autovec/group_overlap/vwadd_wv_vs1-i16-m2.c    | 38 +++++++++++++++++++
 .../autovec/group_overlap/vwadd_wv_vs1-i16-m4.c    | 38 +++++++++++++++++++
 .../autovec/group_overlap/vwadd_wv_vs1-i16-mf2.c   | 30 +++++++++++++++
 .../autovec/group_overlap/vwadd_wv_vs1-i16-mf4.c   | 30 +++++++++++++++
 .../autovec/group_overlap/vwadd_wv_vs1-i32-m1.c    | 38 +++++++++++++++++++
 .../autovec/group_overlap/vwadd_wv_vs1-i32-m2.c    | 38 +++++++++++++++++++
 .../autovec/group_overlap/vwadd_wv_vs1-i32-m4.c    | 38 +++++++++++++++++++
 .../autovec/group_overlap/vwadd_wv_vs1-i32-mf2.c   | 30 +++++++++++++++
 .../rvv/autovec/group_overlap/vwadd_wv_vs1-i8-m1.c | 38 +++++++++++++++++++
 .../rvv/autovec/group_overlap/vwadd_wv_vs1-i8-m2.c | 38 +++++++++++++++++++
 .../rvv/autovec/group_overlap/vwadd_wv_vs1-i8-m4.c | 38 +++++++++++++++++++
 .../autovec/group_overlap/vwadd_wv_vs1-i8-mf2.c    | 30 +++++++++++++++
 .../autovec/group_overlap/vwadd_wv_vs1-i8-mf4.c    | 30 +++++++++++++++
 .../autovec/group_overlap/vwadd_wv_vs1-i8-mf8.c    | 30 +++++++++++++++
 16 files changed, 566 insertions(+)

diff --git 
a/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/group_overlap.h 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/group_overlap.h
index 20044c28c5a8..59129a476394 100644
--- a/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/group_overlap.h
+++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/group_overlap.h
@@ -777,6 +777,34 @@
     ST_F ((void *)out, vd0, VL); OUT += VL;                                 \
     ST_F ((void *)out, vd1, VL); OUT += VL;                                 \
 
+/* A widening binary insn of the wv form like vwadd.wv reads vs2 with
+   EEW = 2 * SEW while vs1 is read with EEW = SEW, thus vs1 must not fall
+   inside the vs2 register group.  PICK0_F and PICK1_F reinterpret the wide
+   source vs2 as the narrowed element type and extract one piece of it, which
+   lives in the vs2 register group.  Then take that piece as vs1 to ask for
+   the overlap.  The wide source is stored after the insn to keep it alive, 
thus
+   the destination cannot simply reuse the vs2 register group.  */
+#define LOOP_WIDEN_BINARY_WV_BODY_OVERLAP_X2(NT, WT, LD_WF, PICK0_F,        \
+                                            PICK1_F, OUT_F, ST_F, OUT,     \
+                                            START, VL)                     \
+    WT vw0 = LD_WF ((void *)START, VL); START += VL;                        \
+    WT vw1 = LD_WF ((void *)START, VL); START += VL;                        \
+                                                                            \
+    asm volatile("nop" ::: "memory");                                       \
+                                                                            \
+    NT vt0 = PICK0_F (vw0);                                                 \
+    NT vt1 = PICK1_F (vw1);                                                 \
+                                                                            \
+    WT vd0 = OUT_F (vw0, vt0, VL);                                          \
+    WT vd1 = OUT_F (vw1, vt1, VL);                                          \
+                                                                            \
+    asm volatile("nop" ::: "memory");                                       \
+                                                                            \
+    ST_F ((void *)out, vd0, VL); OUT += VL;                                 \
+    ST_F ((void *)out, vd1, VL); OUT += VL;                                 \
+    ST_F ((void *)out, vw0, VL); OUT += VL;                                 \
+    ST_F ((void *)out, vw1, VL); OUT += VL;                                 \
+
 #define DEF_GROUP_OVERLAP_UNARY_0(VL_F, NT, WT, LD_F, OUT_F, ST_F, NAME, \
                                  LOOP_BODY)                             \
   void test_group_overlap_##NAME##_##NT##_unary_0(uint8_t *data,         \
@@ -854,6 +882,22 @@
     }                                                                       \
   }
 
+#define DEF_GROUP_OVERLAP_BINARY_4(VL_F, NT, WT, LD_WF, PICK0_F, PICK1_F,   \
+                                  OUT_F, ST_F, NAME, LOOP_BODY)            \
+  void test_group_overlap_##NAME##_##NT##_binary_4(uint8_t *data,           \
+                                                  uint8_t *out,            \
+                                                  size_t limit)            \
+  {                                                                         \
+    uint8_t *start = data;                                                  \
+    uint8_t *end = data + limit;                                            \
+    size_t vl = VL_F ();                                                    \
+                                                                            \
+    while (start < end) {                                                   \
+      LOOP_BODY (NT, WT, LD_WF, PICK0_F, PICK1_F, OUT_F, ST_F, out, start,  \
+                vl);                                                       \
+    }                                                                       \
+  }
+
 #define DEF_GROUP_OVERLAP_REDUCE_0(VL_F, NT, WT, WNT, LD_NF, RI_F, GET_F,   \
                                   IDX, OUT_F, ST_F, NAME, LOOP_BODY)       \
   void test_group_overlap_##NAME##_##NT##_reduce_0(uint8_t *data,           \
diff --git 
a/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwadd_wv_vs1-i16-m1.c
 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwadd_wv_vs1-i16-m1.c
new file mode 100644
index 000000000000..f396419a4e88
--- /dev/null
+++ 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwadd_wv_vs1-i16-m1.c
@@ -0,0 +1,38 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gcv -mabi=lp64d" } */
+
+#include "group_overlap.h"
+
+static vint16m1_t
+pick1_i16m2_i16m1 (vint32m2_t v)
+{
+  vint16m2_t n = __riscv_vreinterpret_v_i32m2_i16m2 (v);
+
+  return __riscv_vget_v_i16m2_i16m1 (n, 1);
+}
+
+static vint16m1_t
+pick0_i16m2_i16m1 (vint32m2_t v)
+{
+  vint16m2_t n = __riscv_vreinterpret_v_i32m2_i16m2 (v);
+
+  return __riscv_vget_v_i16m2_i16m1 (n, 0);
+}
+
+DEF_GROUP_OVERLAP_BINARY_4(
+  __riscv_vsetvlmax_e16m1,
+  vint16m1_t,
+  vint32m2_t,
+  __riscv_vle32_v_i32m2,
+  pick1_i16m2_i16m1,
+  pick0_i16m2_i16m1,
+  __riscv_vwadd_wv_i32m2,
+  __riscv_vse32_v_i32m2,
+  vwadd_wv_vs1,
+  LOOP_WIDEN_BINARY_WV_BODY_OVERLAP_X2)
+
+/* The vs1 is read with EEW = SEW while the vs2 is read with EEW = 2 * SEW,
+   thus vs1 must not fall inside the vs2 register group.  */
+/* { dg-final { scan-assembler-times {vwadd\.wv\s+v10,v0,v2([^0-9]|$)} 1 } } */
+/* { dg-final { scan-assembler-times {vwadd\.wv\s+v8,v6,v5([^0-9]|$)} 1 } } */
+/* { dg-final { scan-assembler-not 
{vwadd\.wv\s+v[0-9]+,(v0,v(0|1)|v2,v(2|3)|v4,v(4|5)|v6,v(6|7)|v8,v(8|9)|v10,v(10|11)|v12,v(12|13)|v14,v(14|15)|v16,v(16|17)|v18,v(18|19)|v20,v(20|21)|v22,v(22|23)|v24,v(24|25)|v26,v(26|27)|v28,v(28|29)|v30,v(30|31))([^0-9]|$)}
 } } */
diff --git 
a/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwadd_wv_vs1-i16-m2.c
 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwadd_wv_vs1-i16-m2.c
new file mode 100644
index 000000000000..483ed8ec0c31
--- /dev/null
+++ 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwadd_wv_vs1-i16-m2.c
@@ -0,0 +1,38 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gcv -mabi=lp64d" } */
+
+#include "group_overlap.h"
+
+static vint16m2_t
+pick1_i16m4_i16m2 (vint32m4_t v)
+{
+  vint16m4_t n = __riscv_vreinterpret_v_i32m4_i16m4 (v);
+
+  return __riscv_vget_v_i16m4_i16m2 (n, 1);
+}
+
+static vint16m2_t
+pick0_i16m4_i16m2 (vint32m4_t v)
+{
+  vint16m4_t n = __riscv_vreinterpret_v_i32m4_i16m4 (v);
+
+  return __riscv_vget_v_i16m4_i16m2 (n, 0);
+}
+
+DEF_GROUP_OVERLAP_BINARY_4(
+  __riscv_vsetvlmax_e16m2,
+  vint16m2_t,
+  vint32m4_t,
+  __riscv_vle32_v_i32m4,
+  pick1_i16m4_i16m2,
+  pick0_i16m4_i16m2,
+  __riscv_vwadd_wv_i32m4,
+  __riscv_vse32_v_i32m4,
+  vwadd_wv_vs1,
+  LOOP_WIDEN_BINARY_WV_BODY_OVERLAP_X2)
+
+/* The vs1 is read with EEW = SEW while the vs2 is read with EEW = 2 * SEW,
+   thus vs1 must not fall inside the vs2 register group.  */
+/* { dg-final { scan-assembler-times {vwadd\.wv\s+v16,v12,v10([^0-9]|$)} 1 } } 
*/
+/* { dg-final { scan-assembler-times {vwadd\.wv\s+v20,v0,v4([^0-9]|$)} 1 } } */
+/* { dg-final { scan-assembler-not 
{vwadd\.wv\s+v[0-9]+,(v0,v(0|1|2|3)|v4,v(4|5|6|7)|v8,v(8|9|10|11)|v12,v(12|13|14|15)|v16,v(16|17|18|19)|v20,v(20|21|22|23)|v24,v(24|25|26|27)|v28,v(28|29|30|31))([^0-9]|$)}
 } } */
diff --git 
a/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwadd_wv_vs1-i16-m4.c
 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwadd_wv_vs1-i16-m4.c
new file mode 100644
index 000000000000..eb186fcb2e4d
--- /dev/null
+++ 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwadd_wv_vs1-i16-m4.c
@@ -0,0 +1,38 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gcv -mabi=lp64d" } */
+
+#include "group_overlap.h"
+
+static vint16m4_t
+pick1_i16m8_i16m4 (vint32m8_t v)
+{
+  vint16m8_t n = __riscv_vreinterpret_v_i32m8_i16m8 (v);
+
+  return __riscv_vget_v_i16m8_i16m4 (n, 1);
+}
+
+static vint16m4_t
+pick0_i16m8_i16m4 (vint32m8_t v)
+{
+  vint16m8_t n = __riscv_vreinterpret_v_i32m8_i16m8 (v);
+
+  return __riscv_vget_v_i16m8_i16m4 (n, 0);
+}
+
+DEF_GROUP_OVERLAP_BINARY_4(
+  __riscv_vsetvlmax_e16m4,
+  vint16m4_t,
+  vint32m8_t,
+  __riscv_vle32_v_i32m8,
+  pick1_i16m8_i16m4,
+  pick0_i16m8_i16m4,
+  __riscv_vwadd_wv_i32m8,
+  __riscv_vse32_v_i32m8,
+  vwadd_wv_vs1,
+  LOOP_WIDEN_BINARY_WV_BODY_OVERLAP_X2)
+
+/* The vs1 is read with EEW = SEW while the vs2 is read with EEW = 2 * SEW,
+   thus vs1 must not fall inside the vs2 register group.  */
+/* { dg-final { scan-assembler-times {vwadd\.wv\s+v0,v24,v20([^0-9]|$)} 1 } } 
*/
+/* { dg-final { scan-assembler-times {vwadd\.wv\s+v24,v24,v8([^0-9]|$)} 1 } } 
*/
+/* { dg-final { scan-assembler-not 
{vwadd\.wv\s+v[0-9]+,(v0,v(0|1|2|3|4|5|6|7)|v8,v(8|9|10|11|12|13|14|15)|v16,v(16|17|18|19|20|21|22|23)|v24,v(24|25|26|27|28|29|30|31))([^0-9]|$)}
 } } */
diff --git 
a/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwadd_wv_vs1-i16-mf2.c
 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwadd_wv_vs1-i16-mf2.c
new file mode 100644
index 000000000000..45e6a70e34c5
--- /dev/null
+++ 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwadd_wv_vs1-i16-mf2.c
@@ -0,0 +1,30 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gcv -mabi=lp64d" } */
+
+#include "group_overlap.h"
+
+static vint16mf2_t
+pick_i16m1_i16mf2 (vint32m1_t v)
+{
+  vint16m1_t n = __riscv_vreinterpret_v_i32m1_i16m1 (v);
+
+  return __riscv_vlmul_trunc_v_i16m1_i16mf2 (n);
+}
+
+DEF_GROUP_OVERLAP_BINARY_4(
+  __riscv_vsetvlmax_e16mf2,
+  vint16mf2_t,
+  vint32m1_t,
+  __riscv_vle32_v_i32m1,
+  pick_i16m1_i16mf2,
+  pick_i16m1_i16mf2,
+  __riscv_vwadd_wv_i32m1,
+  __riscv_vse32_v_i32m1,
+  vwadd_wv_vs1,
+  LOOP_WIDEN_BINARY_WV_BODY_OVERLAP_X2)
+
+/* The vs1 is read with EEW = SEW while the vs2 is read with EEW = 2 * SEW,
+   thus vs1 must not fall inside the vs2 register group.  */
+/* { dg-final { scan-assembler-times {vwadd\.wv\s+v4,v3,v2([^0-9]|$)} 1 } } */
+/* { dg-final { scan-assembler-times {vwadd\.wv\s+v5,v0,v1([^0-9]|$)} 1 } } */
+/* { dg-final { scan-assembler-not 
{vwadd\.wv\s+v[0-9]+,(v[0-9]+),\1([^0-9]|$)} } } */
diff --git 
a/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwadd_wv_vs1-i16-mf4.c
 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwadd_wv_vs1-i16-mf4.c
new file mode 100644
index 000000000000..a39c80043214
--- /dev/null
+++ 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwadd_wv_vs1-i16-mf4.c
@@ -0,0 +1,30 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gcv -mabi=lp64d" } */
+
+#include "group_overlap.h"
+
+static vint16mf4_t
+pick_i16mf2_i16mf4 (vint32mf2_t v)
+{
+  vint16mf2_t n = __riscv_vreinterpret_v_i32mf2_i16mf2 (v);
+
+  return __riscv_vlmul_trunc_v_i16mf2_i16mf4 (n);
+}
+
+DEF_GROUP_OVERLAP_BINARY_4(
+  __riscv_vsetvlmax_e16mf4,
+  vint16mf4_t,
+  vint32mf2_t,
+  __riscv_vle32_v_i32mf2,
+  pick_i16mf2_i16mf4,
+  pick_i16mf2_i16mf4,
+  __riscv_vwadd_wv_i32mf2,
+  __riscv_vse32_v_i32mf2,
+  vwadd_wv_vs1,
+  LOOP_WIDEN_BINARY_WV_BODY_OVERLAP_X2)
+
+/* The vs1 is read with EEW = SEW while the vs2 is read with EEW = 2 * SEW,
+   thus vs1 must not fall inside the vs2 register group.  */
+/* { dg-final { scan-assembler-times {vwadd\.wv\s+v4,v3,v2([^0-9]|$)} 1 } } */
+/* { dg-final { scan-assembler-times {vwadd\.wv\s+v5,v0,v1([^0-9]|$)} 1 } } */
+/* { dg-final { scan-assembler-not 
{vwadd\.wv\s+v[0-9]+,(v[0-9]+),\1([^0-9]|$)} } } */
diff --git 
a/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwadd_wv_vs1-i32-m1.c
 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwadd_wv_vs1-i32-m1.c
new file mode 100644
index 000000000000..c08e18b75418
--- /dev/null
+++ 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwadd_wv_vs1-i32-m1.c
@@ -0,0 +1,38 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gcv -mabi=lp64d" } */
+
+#include "group_overlap.h"
+
+static vint32m1_t
+pick1_i32m2_i32m1 (vint64m2_t v)
+{
+  vint32m2_t n = __riscv_vreinterpret_v_i64m2_i32m2 (v);
+
+  return __riscv_vget_v_i32m2_i32m1 (n, 1);
+}
+
+static vint32m1_t
+pick0_i32m2_i32m1 (vint64m2_t v)
+{
+  vint32m2_t n = __riscv_vreinterpret_v_i64m2_i32m2 (v);
+
+  return __riscv_vget_v_i32m2_i32m1 (n, 0);
+}
+
+DEF_GROUP_OVERLAP_BINARY_4(
+  __riscv_vsetvlmax_e32m1,
+  vint32m1_t,
+  vint64m2_t,
+  __riscv_vle64_v_i64m2,
+  pick1_i32m2_i32m1,
+  pick0_i32m2_i32m1,
+  __riscv_vwadd_wv_i64m2,
+  __riscv_vse64_v_i64m2,
+  vwadd_wv_vs1,
+  LOOP_WIDEN_BINARY_WV_BODY_OVERLAP_X2)
+
+/* The vs1 is read with EEW = SEW while the vs2 is read with EEW = 2 * SEW,
+   thus vs1 must not fall inside the vs2 register group.  */
+/* { dg-final { scan-assembler-times {vwadd\.wv\s+v10,v0,v2([^0-9]|$)} 1 } } */
+/* { dg-final { scan-assembler-times {vwadd\.wv\s+v8,v6,v5([^0-9]|$)} 1 } } */
+/* { dg-final { scan-assembler-not 
{vwadd\.wv\s+v[0-9]+,(v0,v(0|1)|v2,v(2|3)|v4,v(4|5)|v6,v(6|7)|v8,v(8|9)|v10,v(10|11)|v12,v(12|13)|v14,v(14|15)|v16,v(16|17)|v18,v(18|19)|v20,v(20|21)|v22,v(22|23)|v24,v(24|25)|v26,v(26|27)|v28,v(28|29)|v30,v(30|31))([^0-9]|$)}
 } } */
diff --git 
a/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwadd_wv_vs1-i32-m2.c
 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwadd_wv_vs1-i32-m2.c
new file mode 100644
index 000000000000..b46411290b74
--- /dev/null
+++ 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwadd_wv_vs1-i32-m2.c
@@ -0,0 +1,38 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gcv -mabi=lp64d" } */
+
+#include "group_overlap.h"
+
+static vint32m2_t
+pick1_i32m4_i32m2 (vint64m4_t v)
+{
+  vint32m4_t n = __riscv_vreinterpret_v_i64m4_i32m4 (v);
+
+  return __riscv_vget_v_i32m4_i32m2 (n, 1);
+}
+
+static vint32m2_t
+pick0_i32m4_i32m2 (vint64m4_t v)
+{
+  vint32m4_t n = __riscv_vreinterpret_v_i64m4_i32m4 (v);
+
+  return __riscv_vget_v_i32m4_i32m2 (n, 0);
+}
+
+DEF_GROUP_OVERLAP_BINARY_4(
+  __riscv_vsetvlmax_e32m2,
+  vint32m2_t,
+  vint64m4_t,
+  __riscv_vle64_v_i64m4,
+  pick1_i32m4_i32m2,
+  pick0_i32m4_i32m2,
+  __riscv_vwadd_wv_i64m4,
+  __riscv_vse64_v_i64m4,
+  vwadd_wv_vs1,
+  LOOP_WIDEN_BINARY_WV_BODY_OVERLAP_X2)
+
+/* The vs1 is read with EEW = SEW while the vs2 is read with EEW = 2 * SEW,
+   thus vs1 must not fall inside the vs2 register group.  */
+/* { dg-final { scan-assembler-times {vwadd\.wv\s+v16,v12,v10([^0-9]|$)} 1 } } 
*/
+/* { dg-final { scan-assembler-times {vwadd\.wv\s+v20,v0,v4([^0-9]|$)} 1 } } */
+/* { dg-final { scan-assembler-not 
{vwadd\.wv\s+v[0-9]+,(v0,v(0|1|2|3)|v4,v(4|5|6|7)|v8,v(8|9|10|11)|v12,v(12|13|14|15)|v16,v(16|17|18|19)|v20,v(20|21|22|23)|v24,v(24|25|26|27)|v28,v(28|29|30|31))([^0-9]|$)}
 } } */
diff --git 
a/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwadd_wv_vs1-i32-m4.c
 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwadd_wv_vs1-i32-m4.c
new file mode 100644
index 000000000000..5440ddbce681
--- /dev/null
+++ 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwadd_wv_vs1-i32-m4.c
@@ -0,0 +1,38 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gcv -mabi=lp64d" } */
+
+#include "group_overlap.h"
+
+static vint32m4_t
+pick1_i32m8_i32m4 (vint64m8_t v)
+{
+  vint32m8_t n = __riscv_vreinterpret_v_i64m8_i32m8 (v);
+
+  return __riscv_vget_v_i32m8_i32m4 (n, 1);
+}
+
+static vint32m4_t
+pick0_i32m8_i32m4 (vint64m8_t v)
+{
+  vint32m8_t n = __riscv_vreinterpret_v_i64m8_i32m8 (v);
+
+  return __riscv_vget_v_i32m8_i32m4 (n, 0);
+}
+
+DEF_GROUP_OVERLAP_BINARY_4(
+  __riscv_vsetvlmax_e32m4,
+  vint32m4_t,
+  vint64m8_t,
+  __riscv_vle64_v_i64m8,
+  pick1_i32m8_i32m4,
+  pick0_i32m8_i32m4,
+  __riscv_vwadd_wv_i64m8,
+  __riscv_vse64_v_i64m8,
+  vwadd_wv_vs1,
+  LOOP_WIDEN_BINARY_WV_BODY_OVERLAP_X2)
+
+/* The vs1 is read with EEW = SEW while the vs2 is read with EEW = 2 * SEW,
+   thus vs1 must not fall inside the vs2 register group.  */
+/* { dg-final { scan-assembler-times {vwadd\.wv\s+v0,v24,v20([^0-9]|$)} 1 } } 
*/
+/* { dg-final { scan-assembler-times {vwadd\.wv\s+v24,v24,v8([^0-9]|$)} 1 } } 
*/
+/* { dg-final { scan-assembler-not 
{vwadd\.wv\s+v[0-9]+,(v0,v(0|1|2|3|4|5|6|7)|v8,v(8|9|10|11|12|13|14|15)|v16,v(16|17|18|19|20|21|22|23)|v24,v(24|25|26|27|28|29|30|31))([^0-9]|$)}
 } } */
diff --git 
a/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwadd_wv_vs1-i32-mf2.c
 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwadd_wv_vs1-i32-mf2.c
new file mode 100644
index 000000000000..fe7c5d16d07a
--- /dev/null
+++ 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwadd_wv_vs1-i32-mf2.c
@@ -0,0 +1,30 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gcv -mabi=lp64d" } */
+
+#include "group_overlap.h"
+
+static vint32mf2_t
+pick_i32m1_i32mf2 (vint64m1_t v)
+{
+  vint32m1_t n = __riscv_vreinterpret_v_i64m1_i32m1 (v);
+
+  return __riscv_vlmul_trunc_v_i32m1_i32mf2 (n);
+}
+
+DEF_GROUP_OVERLAP_BINARY_4(
+  __riscv_vsetvlmax_e32mf2,
+  vint32mf2_t,
+  vint64m1_t,
+  __riscv_vle64_v_i64m1,
+  pick_i32m1_i32mf2,
+  pick_i32m1_i32mf2,
+  __riscv_vwadd_wv_i64m1,
+  __riscv_vse64_v_i64m1,
+  vwadd_wv_vs1,
+  LOOP_WIDEN_BINARY_WV_BODY_OVERLAP_X2)
+
+/* The vs1 is read with EEW = SEW while the vs2 is read with EEW = 2 * SEW,
+   thus vs1 must not fall inside the vs2 register group.  */
+/* { dg-final { scan-assembler-times {vwadd\.wv\s+v4,v3,v2([^0-9]|$)} 1 } } */
+/* { dg-final { scan-assembler-times {vwadd\.wv\s+v5,v0,v1([^0-9]|$)} 1 } } */
+/* { dg-final { scan-assembler-not 
{vwadd\.wv\s+v[0-9]+,(v[0-9]+),\1([^0-9]|$)} } } */
diff --git 
a/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwadd_wv_vs1-i8-m1.c 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwadd_wv_vs1-i8-m1.c
new file mode 100644
index 000000000000..4a33de7ea599
--- /dev/null
+++ 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwadd_wv_vs1-i8-m1.c
@@ -0,0 +1,38 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gcv -mabi=lp64d" } */
+
+#include "group_overlap.h"
+
+static vint8m1_t
+pick1_i8m2_i8m1 (vint16m2_t v)
+{
+  vint8m2_t n = __riscv_vreinterpret_v_i16m2_i8m2 (v);
+
+  return __riscv_vget_v_i8m2_i8m1 (n, 1);
+}
+
+static vint8m1_t
+pick0_i8m2_i8m1 (vint16m2_t v)
+{
+  vint8m2_t n = __riscv_vreinterpret_v_i16m2_i8m2 (v);
+
+  return __riscv_vget_v_i8m2_i8m1 (n, 0);
+}
+
+DEF_GROUP_OVERLAP_BINARY_4(
+  __riscv_vsetvlmax_e8m1,
+  vint8m1_t,
+  vint16m2_t,
+  __riscv_vle16_v_i16m2,
+  pick1_i8m2_i8m1,
+  pick0_i8m2_i8m1,
+  __riscv_vwadd_wv_i16m2,
+  __riscv_vse16_v_i16m2,
+  vwadd_wv_vs1,
+  LOOP_WIDEN_BINARY_WV_BODY_OVERLAP_X2)
+
+/* The vs1 is read with EEW = SEW while the vs2 is read with EEW = 2 * SEW,
+   thus vs1 must not fall inside the vs2 register group.  */
+/* { dg-final { scan-assembler-times {vwadd\.wv\s+v10,v0,v2([^0-9]|$)} 1 } } */
+/* { dg-final { scan-assembler-times {vwadd\.wv\s+v8,v6,v5([^0-9]|$)} 1 } } */
+/* { dg-final { scan-assembler-not 
{vwadd\.wv\s+v[0-9]+,(v0,v(0|1)|v2,v(2|3)|v4,v(4|5)|v6,v(6|7)|v8,v(8|9)|v10,v(10|11)|v12,v(12|13)|v14,v(14|15)|v16,v(16|17)|v18,v(18|19)|v20,v(20|21)|v22,v(22|23)|v24,v(24|25)|v26,v(26|27)|v28,v(28|29)|v30,v(30|31))([^0-9]|$)}
 } } */
diff --git 
a/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwadd_wv_vs1-i8-m2.c 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwadd_wv_vs1-i8-m2.c
new file mode 100644
index 000000000000..e72d6283e026
--- /dev/null
+++ 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwadd_wv_vs1-i8-m2.c
@@ -0,0 +1,38 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gcv -mabi=lp64d" } */
+
+#include "group_overlap.h"
+
+static vint8m2_t
+pick1_i8m4_i8m2 (vint16m4_t v)
+{
+  vint8m4_t n = __riscv_vreinterpret_v_i16m4_i8m4 (v);
+
+  return __riscv_vget_v_i8m4_i8m2 (n, 1);
+}
+
+static vint8m2_t
+pick0_i8m4_i8m2 (vint16m4_t v)
+{
+  vint8m4_t n = __riscv_vreinterpret_v_i16m4_i8m4 (v);
+
+  return __riscv_vget_v_i8m4_i8m2 (n, 0);
+}
+
+DEF_GROUP_OVERLAP_BINARY_4(
+  __riscv_vsetvlmax_e8m2,
+  vint8m2_t,
+  vint16m4_t,
+  __riscv_vle16_v_i16m4,
+  pick1_i8m4_i8m2,
+  pick0_i8m4_i8m2,
+  __riscv_vwadd_wv_i16m4,
+  __riscv_vse16_v_i16m4,
+  vwadd_wv_vs1,
+  LOOP_WIDEN_BINARY_WV_BODY_OVERLAP_X2)
+
+/* The vs1 is read with EEW = SEW while the vs2 is read with EEW = 2 * SEW,
+   thus vs1 must not fall inside the vs2 register group.  */
+/* { dg-final { scan-assembler-times {vwadd\.wv\s+v16,v12,v10([^0-9]|$)} 1 } } 
*/
+/* { dg-final { scan-assembler-times {vwadd\.wv\s+v20,v0,v4([^0-9]|$)} 1 } } */
+/* { dg-final { scan-assembler-not 
{vwadd\.wv\s+v[0-9]+,(v0,v(0|1|2|3)|v4,v(4|5|6|7)|v8,v(8|9|10|11)|v12,v(12|13|14|15)|v16,v(16|17|18|19)|v20,v(20|21|22|23)|v24,v(24|25|26|27)|v28,v(28|29|30|31))([^0-9]|$)}
 } } */
diff --git 
a/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwadd_wv_vs1-i8-m4.c 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwadd_wv_vs1-i8-m4.c
new file mode 100644
index 000000000000..f410a38b2b14
--- /dev/null
+++ 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwadd_wv_vs1-i8-m4.c
@@ -0,0 +1,38 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gcv -mabi=lp64d" } */
+
+#include "group_overlap.h"
+
+static vint8m4_t
+pick1_i8m8_i8m4 (vint16m8_t v)
+{
+  vint8m8_t n = __riscv_vreinterpret_v_i16m8_i8m8 (v);
+
+  return __riscv_vget_v_i8m8_i8m4 (n, 1);
+}
+
+static vint8m4_t
+pick0_i8m8_i8m4 (vint16m8_t v)
+{
+  vint8m8_t n = __riscv_vreinterpret_v_i16m8_i8m8 (v);
+
+  return __riscv_vget_v_i8m8_i8m4 (n, 0);
+}
+
+DEF_GROUP_OVERLAP_BINARY_4(
+  __riscv_vsetvlmax_e8m4,
+  vint8m4_t,
+  vint16m8_t,
+  __riscv_vle16_v_i16m8,
+  pick1_i8m8_i8m4,
+  pick0_i8m8_i8m4,
+  __riscv_vwadd_wv_i16m8,
+  __riscv_vse16_v_i16m8,
+  vwadd_wv_vs1,
+  LOOP_WIDEN_BINARY_WV_BODY_OVERLAP_X2)
+
+/* The vs1 is read with EEW = SEW while the vs2 is read with EEW = 2 * SEW,
+   thus vs1 must not fall inside the vs2 register group.  */
+/* { dg-final { scan-assembler-times {vwadd\.wv\s+v0,v24,v20([^0-9]|$)} 1 } } 
*/
+/* { dg-final { scan-assembler-times {vwadd\.wv\s+v24,v24,v8([^0-9]|$)} 1 } } 
*/
+/* { dg-final { scan-assembler-not 
{vwadd\.wv\s+v[0-9]+,(v0,v(0|1|2|3|4|5|6|7)|v8,v(8|9|10|11|12|13|14|15)|v16,v(16|17|18|19|20|21|22|23)|v24,v(24|25|26|27|28|29|30|31))([^0-9]|$)}
 } } */
diff --git 
a/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwadd_wv_vs1-i8-mf2.c
 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwadd_wv_vs1-i8-mf2.c
new file mode 100644
index 000000000000..9b851187750a
--- /dev/null
+++ 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwadd_wv_vs1-i8-mf2.c
@@ -0,0 +1,30 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gcv -mabi=lp64d" } */
+
+#include "group_overlap.h"
+
+static vint8mf2_t
+pick_i8m1_i8mf2 (vint16m1_t v)
+{
+  vint8m1_t n = __riscv_vreinterpret_v_i16m1_i8m1 (v);
+
+  return __riscv_vlmul_trunc_v_i8m1_i8mf2 (n);
+}
+
+DEF_GROUP_OVERLAP_BINARY_4(
+  __riscv_vsetvlmax_e8mf2,
+  vint8mf2_t,
+  vint16m1_t,
+  __riscv_vle16_v_i16m1,
+  pick_i8m1_i8mf2,
+  pick_i8m1_i8mf2,
+  __riscv_vwadd_wv_i16m1,
+  __riscv_vse16_v_i16m1,
+  vwadd_wv_vs1,
+  LOOP_WIDEN_BINARY_WV_BODY_OVERLAP_X2)
+
+/* The vs1 is read with EEW = SEW while the vs2 is read with EEW = 2 * SEW,
+   thus vs1 must not fall inside the vs2 register group.  */
+/* { dg-final { scan-assembler-times {vwadd\.wv\s+v4,v3,v2([^0-9]|$)} 1 } } */
+/* { dg-final { scan-assembler-times {vwadd\.wv\s+v5,v0,v1([^0-9]|$)} 1 } } */
+/* { dg-final { scan-assembler-not 
{vwadd\.wv\s+v[0-9]+,(v[0-9]+),\1([^0-9]|$)} } } */
diff --git 
a/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwadd_wv_vs1-i8-mf4.c
 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwadd_wv_vs1-i8-mf4.c
new file mode 100644
index 000000000000..3b1e56256b16
--- /dev/null
+++ 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwadd_wv_vs1-i8-mf4.c
@@ -0,0 +1,30 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gcv -mabi=lp64d" } */
+
+#include "group_overlap.h"
+
+static vint8mf4_t
+pick_i8mf2_i8mf4 (vint16mf2_t v)
+{
+  vint8mf2_t n = __riscv_vreinterpret_v_i16mf2_i8mf2 (v);
+
+  return __riscv_vlmul_trunc_v_i8mf2_i8mf4 (n);
+}
+
+DEF_GROUP_OVERLAP_BINARY_4(
+  __riscv_vsetvlmax_e8mf4,
+  vint8mf4_t,
+  vint16mf2_t,
+  __riscv_vle16_v_i16mf2,
+  pick_i8mf2_i8mf4,
+  pick_i8mf2_i8mf4,
+  __riscv_vwadd_wv_i16mf2,
+  __riscv_vse16_v_i16mf2,
+  vwadd_wv_vs1,
+  LOOP_WIDEN_BINARY_WV_BODY_OVERLAP_X2)
+
+/* The vs1 is read with EEW = SEW while the vs2 is read with EEW = 2 * SEW,
+   thus vs1 must not fall inside the vs2 register group.  */
+/* { dg-final { scan-assembler-times {vwadd\.wv\s+v4,v3,v2([^0-9]|$)} 1 } } */
+/* { dg-final { scan-assembler-times {vwadd\.wv\s+v5,v0,v1([^0-9]|$)} 1 } } */
+/* { dg-final { scan-assembler-not 
{vwadd\.wv\s+v[0-9]+,(v[0-9]+),\1([^0-9]|$)} } } */
diff --git 
a/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwadd_wv_vs1-i8-mf8.c
 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwadd_wv_vs1-i8-mf8.c
new file mode 100644
index 000000000000..6714ced57cce
--- /dev/null
+++ 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwadd_wv_vs1-i8-mf8.c
@@ -0,0 +1,30 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gcv -mabi=lp64d" } */
+
+#include "group_overlap.h"
+
+static vint8mf8_t
+pick_i8mf4_i8mf8 (vint16mf4_t v)
+{
+  vint8mf4_t n = __riscv_vreinterpret_v_i16mf4_i8mf4 (v);
+
+  return __riscv_vlmul_trunc_v_i8mf4_i8mf8 (n);
+}
+
+DEF_GROUP_OVERLAP_BINARY_4(
+  __riscv_vsetvlmax_e8mf8,
+  vint8mf8_t,
+  vint16mf4_t,
+  __riscv_vle16_v_i16mf4,
+  pick_i8mf4_i8mf8,
+  pick_i8mf4_i8mf8,
+  __riscv_vwadd_wv_i16mf4,
+  __riscv_vse16_v_i16mf4,
+  vwadd_wv_vs1,
+  LOOP_WIDEN_BINARY_WV_BODY_OVERLAP_X2)
+
+/* The vs1 is read with EEW = SEW while the vs2 is read with EEW = 2 * SEW,
+   thus vs1 must not fall inside the vs2 register group.  */
+/* { dg-final { scan-assembler-times {vwadd\.wv\s+v4,v3,v2([^0-9]|$)} 1 } } */
+/* { dg-final { scan-assembler-times {vwadd\.wv\s+v5,v0,v1([^0-9]|$)} 1 } } */
+/* { dg-final { scan-assembler-not 
{vwadd\.wv\s+v[0-9]+,(v[0-9]+),\1([^0-9]|$)} } } */

Reply via email to