https://gcc.gnu.org/g:4b41a0b5ad47ed3c7b290dfb1070a48d29005a74

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

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

Diff:
---
 .../autovec/group_overlap/vwsub_wv_vs1-i16-m1.c    | 38 ++++++++++++++++++++++
 .../autovec/group_overlap/vwsub_wv_vs1-i16-m2.c    | 38 ++++++++++++++++++++++
 .../autovec/group_overlap/vwsub_wv_vs1-i16-m4.c    | 38 ++++++++++++++++++++++
 .../autovec/group_overlap/vwsub_wv_vs1-i16-mf2.c   | 30 +++++++++++++++++
 .../autovec/group_overlap/vwsub_wv_vs1-i16-mf4.c   | 30 +++++++++++++++++
 .../autovec/group_overlap/vwsub_wv_vs1-i32-m1.c    | 38 ++++++++++++++++++++++
 .../autovec/group_overlap/vwsub_wv_vs1-i32-m2.c    | 38 ++++++++++++++++++++++
 .../autovec/group_overlap/vwsub_wv_vs1-i32-m4.c    | 38 ++++++++++++++++++++++
 .../autovec/group_overlap/vwsub_wv_vs1-i32-mf2.c   | 30 +++++++++++++++++
 .../rvv/autovec/group_overlap/vwsub_wv_vs1-i8-m1.c | 38 ++++++++++++++++++++++
 .../rvv/autovec/group_overlap/vwsub_wv_vs1-i8-m2.c | 38 ++++++++++++++++++++++
 .../rvv/autovec/group_overlap/vwsub_wv_vs1-i8-m4.c | 38 ++++++++++++++++++++++
 .../autovec/group_overlap/vwsub_wv_vs1-i8-mf2.c    | 30 +++++++++++++++++
 .../autovec/group_overlap/vwsub_wv_vs1-i8-mf4.c    | 30 +++++++++++++++++
 .../autovec/group_overlap/vwsub_wv_vs1-i8-mf8.c    | 30 +++++++++++++++++
 15 files changed, 522 insertions(+)

diff --git 
a/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwsub_wv_vs1-i16-m1.c
 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwsub_wv_vs1-i16-m1.c
new file mode 100644
index 000000000000..84fb9e75336c
--- /dev/null
+++ 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwsub_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_vwsub_wv_i32m2,
+  __riscv_vse32_v_i32m2,
+  vwsub_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 {vwsub\.wv\s+v10,v0,v2([^0-9]|$)} 1 } } */
+/* { dg-final { scan-assembler-times {vwsub\.wv\s+v8,v6,v5([^0-9]|$)} 1 } } */
+/* { dg-final { scan-assembler-not 
{vwsub\.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/vwsub_wv_vs1-i16-m2.c
 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwsub_wv_vs1-i16-m2.c
new file mode 100644
index 000000000000..fab3bcb70ab0
--- /dev/null
+++ 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwsub_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_vwsub_wv_i32m4,
+  __riscv_vse32_v_i32m4,
+  vwsub_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 {vwsub\.wv\s+v16,v12,v10([^0-9]|$)} 1 } } 
*/
+/* { dg-final { scan-assembler-times {vwsub\.wv\s+v20,v0,v4([^0-9]|$)} 1 } } */
+/* { dg-final { scan-assembler-not 
{vwsub\.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/vwsub_wv_vs1-i16-m4.c
 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwsub_wv_vs1-i16-m4.c
new file mode 100644
index 000000000000..e87d1e7cec68
--- /dev/null
+++ 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwsub_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_vwsub_wv_i32m8,
+  __riscv_vse32_v_i32m8,
+  vwsub_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 {vwsub\.wv\s+v0,v24,v20([^0-9]|$)} 1 } } 
*/
+/* { dg-final { scan-assembler-times {vwsub\.wv\s+v24,v24,v8([^0-9]|$)} 1 } } 
*/
+/* { dg-final { scan-assembler-not 
{vwsub\.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/vwsub_wv_vs1-i16-mf2.c
 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwsub_wv_vs1-i16-mf2.c
new file mode 100644
index 000000000000..47cf5b44843f
--- /dev/null
+++ 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwsub_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_vwsub_wv_i32m1,
+  __riscv_vse32_v_i32m1,
+  vwsub_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 {vwsub\.wv\s+v4,v3,v2([^0-9]|$)} 1 } } */
+/* { dg-final { scan-assembler-times {vwsub\.wv\s+v5,v0,v1([^0-9]|$)} 1 } } */
+/* { dg-final { scan-assembler-not 
{vwsub\.wv\s+v[0-9]+,(v[0-9]+),\1([^0-9]|$)} } } */
diff --git 
a/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwsub_wv_vs1-i16-mf4.c
 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwsub_wv_vs1-i16-mf4.c
new file mode 100644
index 000000000000..ccf8611c7afb
--- /dev/null
+++ 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwsub_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_vwsub_wv_i32mf2,
+  __riscv_vse32_v_i32mf2,
+  vwsub_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 {vwsub\.wv\s+v4,v3,v2([^0-9]|$)} 1 } } */
+/* { dg-final { scan-assembler-times {vwsub\.wv\s+v5,v0,v1([^0-9]|$)} 1 } } */
+/* { dg-final { scan-assembler-not 
{vwsub\.wv\s+v[0-9]+,(v[0-9]+),\1([^0-9]|$)} } } */
diff --git 
a/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwsub_wv_vs1-i32-m1.c
 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwsub_wv_vs1-i32-m1.c
new file mode 100644
index 000000000000..e7f2f5557f38
--- /dev/null
+++ 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwsub_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_vwsub_wv_i64m2,
+  __riscv_vse64_v_i64m2,
+  vwsub_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 {vwsub\.wv\s+v10,v0,v2([^0-9]|$)} 1 } } */
+/* { dg-final { scan-assembler-times {vwsub\.wv\s+v8,v6,v5([^0-9]|$)} 1 } } */
+/* { dg-final { scan-assembler-not 
{vwsub\.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/vwsub_wv_vs1-i32-m2.c
 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwsub_wv_vs1-i32-m2.c
new file mode 100644
index 000000000000..f85295b8af33
--- /dev/null
+++ 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwsub_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_vwsub_wv_i64m4,
+  __riscv_vse64_v_i64m4,
+  vwsub_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 {vwsub\.wv\s+v16,v12,v10([^0-9]|$)} 1 } } 
*/
+/* { dg-final { scan-assembler-times {vwsub\.wv\s+v20,v0,v4([^0-9]|$)} 1 } } */
+/* { dg-final { scan-assembler-not 
{vwsub\.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/vwsub_wv_vs1-i32-m4.c
 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwsub_wv_vs1-i32-m4.c
new file mode 100644
index 000000000000..e66fe16a4beb
--- /dev/null
+++ 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwsub_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_vwsub_wv_i64m8,
+  __riscv_vse64_v_i64m8,
+  vwsub_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 {vwsub\.wv\s+v0,v24,v20([^0-9]|$)} 1 } } 
*/
+/* { dg-final { scan-assembler-times {vwsub\.wv\s+v24,v24,v8([^0-9]|$)} 1 } } 
*/
+/* { dg-final { scan-assembler-not 
{vwsub\.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/vwsub_wv_vs1-i32-mf2.c
 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwsub_wv_vs1-i32-mf2.c
new file mode 100644
index 000000000000..e22a76c74a42
--- /dev/null
+++ 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwsub_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_vwsub_wv_i64m1,
+  __riscv_vse64_v_i64m1,
+  vwsub_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 {vwsub\.wv\s+v4,v3,v2([^0-9]|$)} 1 } } */
+/* { dg-final { scan-assembler-times {vwsub\.wv\s+v5,v0,v1([^0-9]|$)} 1 } } */
+/* { dg-final { scan-assembler-not 
{vwsub\.wv\s+v[0-9]+,(v[0-9]+),\1([^0-9]|$)} } } */
diff --git 
a/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwsub_wv_vs1-i8-m1.c 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwsub_wv_vs1-i8-m1.c
new file mode 100644
index 000000000000..5376323791c1
--- /dev/null
+++ 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwsub_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_vwsub_wv_i16m2,
+  __riscv_vse16_v_i16m2,
+  vwsub_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 {vwsub\.wv\s+v10,v0,v2([^0-9]|$)} 1 } } */
+/* { dg-final { scan-assembler-times {vwsub\.wv\s+v8,v6,v5([^0-9]|$)} 1 } } */
+/* { dg-final { scan-assembler-not 
{vwsub\.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/vwsub_wv_vs1-i8-m2.c 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwsub_wv_vs1-i8-m2.c
new file mode 100644
index 000000000000..dd5d9cba7779
--- /dev/null
+++ 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwsub_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_vwsub_wv_i16m4,
+  __riscv_vse16_v_i16m4,
+  vwsub_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 {vwsub\.wv\s+v16,v12,v10([^0-9]|$)} 1 } } 
*/
+/* { dg-final { scan-assembler-times {vwsub\.wv\s+v20,v0,v4([^0-9]|$)} 1 } } */
+/* { dg-final { scan-assembler-not 
{vwsub\.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/vwsub_wv_vs1-i8-m4.c 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwsub_wv_vs1-i8-m4.c
new file mode 100644
index 000000000000..32c6bff0c400
--- /dev/null
+++ 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwsub_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_vwsub_wv_i16m8,
+  __riscv_vse16_v_i16m8,
+  vwsub_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 {vwsub\.wv\s+v0,v24,v20([^0-9]|$)} 1 } } 
*/
+/* { dg-final { scan-assembler-times {vwsub\.wv\s+v24,v24,v8([^0-9]|$)} 1 } } 
*/
+/* { dg-final { scan-assembler-not 
{vwsub\.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/vwsub_wv_vs1-i8-mf2.c
 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwsub_wv_vs1-i8-mf2.c
new file mode 100644
index 000000000000..1eecc34b18eb
--- /dev/null
+++ 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwsub_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_vwsub_wv_i16m1,
+  __riscv_vse16_v_i16m1,
+  vwsub_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 {vwsub\.wv\s+v4,v3,v2([^0-9]|$)} 1 } } */
+/* { dg-final { scan-assembler-times {vwsub\.wv\s+v5,v0,v1([^0-9]|$)} 1 } } */
+/* { dg-final { scan-assembler-not 
{vwsub\.wv\s+v[0-9]+,(v[0-9]+),\1([^0-9]|$)} } } */
diff --git 
a/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwsub_wv_vs1-i8-mf4.c
 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwsub_wv_vs1-i8-mf4.c
new file mode 100644
index 000000000000..d160874368ae
--- /dev/null
+++ 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwsub_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_vwsub_wv_i16mf2,
+  __riscv_vse16_v_i16mf2,
+  vwsub_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 {vwsub\.wv\s+v4,v3,v2([^0-9]|$)} 1 } } */
+/* { dg-final { scan-assembler-times {vwsub\.wv\s+v5,v0,v1([^0-9]|$)} 1 } } */
+/* { dg-final { scan-assembler-not 
{vwsub\.wv\s+v[0-9]+,(v[0-9]+),\1([^0-9]|$)} } } */
diff --git 
a/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwsub_wv_vs1-i8-mf8.c
 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwsub_wv_vs1-i8-mf8.c
new file mode 100644
index 000000000000..3679c6dc327a
--- /dev/null
+++ 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vwsub_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_vwsub_wv_i16mf4,
+  __riscv_vse16_v_i16mf4,
+  vwsub_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 {vwsub\.wv\s+v4,v3,v2([^0-9]|$)} 1 } } */
+/* { dg-final { scan-assembler-times {vwsub\.wv\s+v5,v0,v1([^0-9]|$)} 1 } } */
+/* { dg-final { scan-assembler-not 
{vwsub\.wv\s+v[0-9]+,(v[0-9]+),\1([^0-9]|$)} } } */

Reply via email to