https://gcc.gnu.org/g:4710c505b10c7f6faac3c6315c307b8db10169e8
commit r17-5912-g4710c505b10c7f6faac3c6315c307b8db10169e8 Author: Pan Li <[email protected]> Date: Mon Nov 2 10:18:01 2026 +0800 RISC-V: Add test cases for vfwredosum.vs reg overlap Add test cases to ensure the vs1 of the vfwredosum.vs doesn't overlap the register group of the vs2. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f16-m1.c: New test. * gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f16-m2.c: New test. * gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f16-m4.c: New test. * gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f16-m8.c: New test. * gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f32-m1.c: New test. * gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f32-m2.c: New test. * gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f32-m4.c: New test. * gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f32-m8.c: New test. Signed-off-by: Pan Li <[email protected]> Diff: --- .../autovec/group_overlap/vfwredosum_vs-f16-m1.c | 29 ++++++++++++++++++++ .../autovec/group_overlap/vfwredosum_vs-f16-m2.c | 32 ++++++++++++++++++++++ .../autovec/group_overlap/vfwredosum_vs-f16-m4.c | 32 ++++++++++++++++++++++ .../autovec/group_overlap/vfwredosum_vs-f16-m8.c | 32 ++++++++++++++++++++++ .../autovec/group_overlap/vfwredosum_vs-f32-m1.c | 29 ++++++++++++++++++++ .../autovec/group_overlap/vfwredosum_vs-f32-m2.c | 32 ++++++++++++++++++++++ .../autovec/group_overlap/vfwredosum_vs-f32-m4.c | 32 ++++++++++++++++++++++ .../autovec/group_overlap/vfwredosum_vs-f32-m8.c | 32 ++++++++++++++++++++++ 8 files changed, 250 insertions(+) diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f16-m1.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f16-m1.c new file mode 100644 index 000000000000..229bca72a3b5 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f16-m1.c @@ -0,0 +1,29 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv_zvfh -mabi=lp64d" } */ + +#include "group_overlap.h" + +static vfloat32m1_t +reinterpret_f16m1_f32m1 (vfloat16m1_t v) +{ + vuint16m1_t u = __riscv_vreinterpret_v_f16m1_u16m1 (v); + vuint32m1_t wu = __riscv_vreinterpret_v_u16m1_u32m1 (u); + + return __riscv_vreinterpret_v_u32m1_f32m1 (wu); +} + +DEF_GROUP_OVERLAP_REDUCE_1( + __riscv_vsetvlmax_e16m1, + vfloat16m1_t, + vfloat32m1_t, + __riscv_vle16_v_f16m1, + reinterpret_f16m1_f32m1, + __riscv_vfwredosum_vs_f16m1_f32m1, + __riscv_vse32_v_f32m1, + vfwredosum_vs, + LOOP_WIDEN_REDUCE_BODY_OVERLAP_LMUL1_X2) + +/* { dg-final { scan-assembler-times {vfwredosum\.vs\s+v0,v2,v3([^0-9]|$)} 1 } } */ +/* { dg-final { scan-assembler-times {vfwredosum\.vs\s+v5,v1,v4([^0-9]|$)} 1 } } */ +/* { dg-final { scan-assembler-not {vfwredosum\.vs\s+v[0-9]+,v1,v1([^0-9]|$)} } } */ +/* { dg-final { scan-assembler-not {vfwredosum\.vs\s+v[0-9]+,v2,v2([^0-9]|$)} } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f16-m2.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f16-m2.c new file mode 100644 index 000000000000..9905eb23ea16 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f16-m2.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv_zvfh -mabi=lp64d" } */ + +#include "group_overlap.h" + +static vfloat32m2_t +reinterpret_f16m2_f32m2 (vfloat16m2_t v) +{ + vuint16m2_t u = __riscv_vreinterpret_v_f16m2_u16m2 (v); + vuint32m2_t wu = __riscv_vreinterpret_v_u16m2_u32m2 (u); + + return __riscv_vreinterpret_v_u32m2_f32m2 (wu); +} + +DEF_GROUP_OVERLAP_REDUCE_0( + __riscv_vsetvlmax_e16m2, + vfloat16m2_t, + vfloat32m1_t, + vfloat32m2_t, + __riscv_vle16_v_f16m2, + reinterpret_f16m2_f32m2, + __riscv_vget_v_f32m2_f32m1, + 1, + __riscv_vfwredosum_vs_f16m2_f32m1, + __riscv_vse32_v_f32m1, + vfwredosum_vs, + LOOP_WIDEN_REDUCE_BODY_OVERLAP_X2) + +/* { dg-final { scan-assembler-times {vfwredosum\.vs\s+v4,v4,v1([^0-9]|$)} 1 } } */ +/* { dg-final { scan-assembler-times {vfwredosum\.vs\s+v2,v2,v0([^0-9]|$)} 1 } } */ +/* { dg-final { scan-assembler-not {vfwredosum\.vs\s+v[0-9]+,v2,v(2|3)([^0-9]|$)} } } */ +/* { dg-final { scan-assembler-not {vfwredosum\.vs\s+v[0-9]+,v4,v(4|5)([^0-9]|$)} } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f16-m4.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f16-m4.c new file mode 100644 index 000000000000..6fc6bd441e7a --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f16-m4.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv_zvfh -mabi=lp64d" } */ + +#include "group_overlap.h" + +static vfloat32m4_t +reinterpret_f16m4_f32m4 (vfloat16m4_t v) +{ + vuint16m4_t u = __riscv_vreinterpret_v_f16m4_u16m4 (v); + vuint32m4_t wu = __riscv_vreinterpret_v_u16m4_u32m4 (u); + + return __riscv_vreinterpret_v_u32m4_f32m4 (wu); +} + +DEF_GROUP_OVERLAP_REDUCE_0( + __riscv_vsetvlmax_e16m4, + vfloat16m4_t, + vfloat32m1_t, + vfloat32m4_t, + __riscv_vle16_v_f16m4, + reinterpret_f16m4_f32m4, + __riscv_vget_v_f32m4_f32m1, + 3, + __riscv_vfwredosum_vs_f16m4_f32m1, + __riscv_vse32_v_f32m1, + vfwredosum_vs, + LOOP_WIDEN_REDUCE_BODY_OVERLAP_X2) + +/* { dg-final { scan-assembler-times {vfwredosum\.vs\s+v8,v8,v1([^0-9]|$)} 1 } } */ +/* { dg-final { scan-assembler-times {vfwredosum\.vs\s+v4,v4,v0([^0-9]|$)} 1 } } */ +/* { dg-final { scan-assembler-not {vfwredosum\.vs\s+v[0-9]+,v4,v(4|5|6|7)([^0-9]|$)} } } */ +/* { dg-final { scan-assembler-not {vfwredosum\.vs\s+v[0-9]+,v8,v(8|9|10|11)([^0-9]|$)} } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f16-m8.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f16-m8.c new file mode 100644 index 000000000000..107341e14bc8 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f16-m8.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv_zvfh -mabi=lp64d" } */ + +#include "group_overlap.h" + +static vfloat32m8_t +reinterpret_f16m8_f32m8 (vfloat16m8_t v) +{ + vuint16m8_t u = __riscv_vreinterpret_v_f16m8_u16m8 (v); + vuint32m8_t wu = __riscv_vreinterpret_v_u16m8_u32m8 (u); + + return __riscv_vreinterpret_v_u32m8_f32m8 (wu); +} + +DEF_GROUP_OVERLAP_REDUCE_0( + __riscv_vsetvlmax_e16m8, + vfloat16m8_t, + vfloat32m1_t, + vfloat32m8_t, + __riscv_vle16_v_f16m8, + reinterpret_f16m8_f32m8, + __riscv_vget_v_f32m8_f32m1, + 7, + __riscv_vfwredosum_vs_f16m8_f32m1, + __riscv_vse32_v_f32m1, + vfwredosum_vs, + LOOP_WIDEN_REDUCE_BODY_OVERLAP_X2) + +/* { dg-final { scan-assembler-times {vfwredosum\.vs\s+v16,v16,v1([^0-9]|$)} 1 } } */ +/* { dg-final { scan-assembler-times {vfwredosum\.vs\s+v8,v8,v0([^0-9]|$)} 1 } } */ +/* { dg-final { scan-assembler-not {vfwredosum\.vs\s+v[0-9]+,v8,v(8|9|10|11|12|13|14|15)([^0-9]|$)} } } */ +/* { dg-final { scan-assembler-not {vfwredosum\.vs\s+v[0-9]+,v16,v(16|17|18|19|20|21|22|23)([^0-9]|$)} } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f32-m1.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f32-m1.c new file mode 100644 index 000000000000..9b7542959d24 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f32-m1.c @@ -0,0 +1,29 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d" } */ + +#include "group_overlap.h" + +static vfloat64m1_t +reinterpret_f32m1_f64m1 (vfloat32m1_t v) +{ + vuint32m1_t u = __riscv_vreinterpret_v_f32m1_u32m1 (v); + vuint64m1_t wu = __riscv_vreinterpret_v_u32m1_u64m1 (u); + + return __riscv_vreinterpret_v_u64m1_f64m1 (wu); +} + +DEF_GROUP_OVERLAP_REDUCE_1( + __riscv_vsetvlmax_e32m1, + vfloat32m1_t, + vfloat64m1_t, + __riscv_vle32_v_f32m1, + reinterpret_f32m1_f64m1, + __riscv_vfwredosum_vs_f32m1_f64m1, + __riscv_vse64_v_f64m1, + vfwredosum_vs, + LOOP_WIDEN_REDUCE_BODY_OVERLAP_LMUL1_X2) + +/* { dg-final { scan-assembler-times {vfwredosum\.vs\s+v0,v2,v3([^0-9]|$)} 1 } } */ +/* { dg-final { scan-assembler-times {vfwredosum\.vs\s+v5,v1,v4([^0-9]|$)} 1 } } */ +/* { dg-final { scan-assembler-not {vfwredosum\.vs\s+v[0-9]+,v1,v1([^0-9]|$)} } } */ +/* { dg-final { scan-assembler-not {vfwredosum\.vs\s+v[0-9]+,v2,v2([^0-9]|$)} } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f32-m2.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f32-m2.c new file mode 100644 index 000000000000..6efdacc639fc --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f32-m2.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d" } */ + +#include "group_overlap.h" + +static vfloat64m2_t +reinterpret_f32m2_f64m2 (vfloat32m2_t v) +{ + vuint32m2_t u = __riscv_vreinterpret_v_f32m2_u32m2 (v); + vuint64m2_t wu = __riscv_vreinterpret_v_u32m2_u64m2 (u); + + return __riscv_vreinterpret_v_u64m2_f64m2 (wu); +} + +DEF_GROUP_OVERLAP_REDUCE_0( + __riscv_vsetvlmax_e32m2, + vfloat32m2_t, + vfloat64m1_t, + vfloat64m2_t, + __riscv_vle32_v_f32m2, + reinterpret_f32m2_f64m2, + __riscv_vget_v_f64m2_f64m1, + 1, + __riscv_vfwredosum_vs_f32m2_f64m1, + __riscv_vse64_v_f64m1, + vfwredosum_vs, + LOOP_WIDEN_REDUCE_BODY_OVERLAP_X2) + +/* { dg-final { scan-assembler-times {vfwredosum\.vs\s+v4,v4,v1([^0-9]|$)} 1 } } */ +/* { dg-final { scan-assembler-times {vfwredosum\.vs\s+v2,v2,v0([^0-9]|$)} 1 } } */ +/* { dg-final { scan-assembler-not {vfwredosum\.vs\s+v[0-9]+,v2,v(2|3)([^0-9]|$)} } } */ +/* { dg-final { scan-assembler-not {vfwredosum\.vs\s+v[0-9]+,v4,v(4|5)([^0-9]|$)} } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f32-m4.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f32-m4.c new file mode 100644 index 000000000000..4d8f6eff6b66 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f32-m4.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d" } */ + +#include "group_overlap.h" + +static vfloat64m4_t +reinterpret_f32m4_f64m4 (vfloat32m4_t v) +{ + vuint32m4_t u = __riscv_vreinterpret_v_f32m4_u32m4 (v); + vuint64m4_t wu = __riscv_vreinterpret_v_u32m4_u64m4 (u); + + return __riscv_vreinterpret_v_u64m4_f64m4 (wu); +} + +DEF_GROUP_OVERLAP_REDUCE_0( + __riscv_vsetvlmax_e32m4, + vfloat32m4_t, + vfloat64m1_t, + vfloat64m4_t, + __riscv_vle32_v_f32m4, + reinterpret_f32m4_f64m4, + __riscv_vget_v_f64m4_f64m1, + 3, + __riscv_vfwredosum_vs_f32m4_f64m1, + __riscv_vse64_v_f64m1, + vfwredosum_vs, + LOOP_WIDEN_REDUCE_BODY_OVERLAP_X2) + +/* { dg-final { scan-assembler-times {vfwredosum\.vs\s+v8,v8,v1([^0-9]|$)} 1 } } */ +/* { dg-final { scan-assembler-times {vfwredosum\.vs\s+v4,v4,v0([^0-9]|$)} 1 } } */ +/* { dg-final { scan-assembler-not {vfwredosum\.vs\s+v[0-9]+,v4,v(4|5|6|7)([^0-9]|$)} } } */ +/* { dg-final { scan-assembler-not {vfwredosum\.vs\s+v[0-9]+,v8,v(8|9|10|11)([^0-9]|$)} } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f32-m8.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f32-m8.c new file mode 100644 index 000000000000..666527660539 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/group_overlap/vfwredosum_vs-f32-m8.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64d" } */ + +#include "group_overlap.h" + +static vfloat64m8_t +reinterpret_f32m8_f64m8 (vfloat32m8_t v) +{ + vuint32m8_t u = __riscv_vreinterpret_v_f32m8_u32m8 (v); + vuint64m8_t wu = __riscv_vreinterpret_v_u32m8_u64m8 (u); + + return __riscv_vreinterpret_v_u64m8_f64m8 (wu); +} + +DEF_GROUP_OVERLAP_REDUCE_0( + __riscv_vsetvlmax_e32m8, + vfloat32m8_t, + vfloat64m1_t, + vfloat64m8_t, + __riscv_vle32_v_f32m8, + reinterpret_f32m8_f64m8, + __riscv_vget_v_f64m8_f64m1, + 7, + __riscv_vfwredosum_vs_f32m8_f64m1, + __riscv_vse64_v_f64m1, + vfwredosum_vs, + LOOP_WIDEN_REDUCE_BODY_OVERLAP_X2) + +/* { dg-final { scan-assembler-times {vfwredosum\.vs\s+v16,v16,v1([^0-9]|$)} 1 } } */ +/* { dg-final { scan-assembler-times {vfwredosum\.vs\s+v8,v8,v0([^0-9]|$)} 1 } } */ +/* { dg-final { scan-assembler-not {vfwredosum\.vs\s+v[0-9]+,v8,v(8|9|10|11|12|13|14|15)([^0-9]|$)} } } */ +/* { dg-final { scan-assembler-not {vfwredosum\.vs\s+v[0-9]+,v16,v(16|17|18|19|20|21|22|23)([^0-9]|$)} } } */
