Use a template macro to factorize the existing test functions. This patch also adds a version to check subtraction with __fp16 type.
2021-04-26 Christophe Lyon <christophe.l...@linaro.org> gcc/testsuite/ * gcc.target/arm/simd/mve-vsub_1.c: Factorize and add __fp16 test. --- gcc/testsuite/gcc.target/arm/simd/mve-vsub_1.c | 60 +++++++++----------------- 1 file changed, 21 insertions(+), 39 deletions(-) diff --git a/gcc/testsuite/gcc.target/arm/simd/mve-vsub_1.c b/gcc/testsuite/gcc.target/arm/simd/mve-vsub_1.c index 842e5c6..5a6c345 100644 --- a/gcc/testsuite/gcc.target/arm/simd/mve-vsub_1.c +++ b/gcc/testsuite/gcc.target/arm/simd/mve-vsub_1.c @@ -5,60 +5,42 @@ #include <stdint.h> -void test_vsub_i32 (int32_t * dest, int32_t * a, int32_t * b) { - int i; - for (i=0; i<4; i++) { - dest[i] = a[i] - b[i]; - } +#define FUNC(SIGN, TYPE, BITS, NB, OP, NAME) \ + void test_ ## NAME ##_ ## SIGN ## BITS ## x ## NB (TYPE##BITS##_t * __restrict__ dest, \ + TYPE##BITS##_t *a, TYPE##BITS##_t *b) { \ + int i; \ + for (i=0; i<NB; i++) { \ + dest[i] = a[i] OP b[i]; \ + } \ } -void test_vsub_i32_u (uint32_t * dest, uint32_t * a, uint32_t * b) { - int i; - for (i=0; i<4; i++) { - dest[i] = a[i] - b[i]; - } -} +/* 128-bit vectors. */ +FUNC(s, int, 32, 4, -, vsub) +FUNC(u, uint, 32, 4, -, vsub) +FUNC(s, int, 16, 8, -, vsub) +FUNC(u, uint, 16, 8, -, vsub) +FUNC(s, int, 8, 16, -, vsub) +FUNC(u, uint, 8, 16, -, vsub) /* { dg-final { scan-assembler-times {vsub\.i32\tq[0-9]+, q[0-9]+, q[0-9]+} 2 } } */ - -void test_vsub_i16 (int16_t * dest, int16_t * a, int16_t * b) { - int i; - for (i=0; i<8; i++) { - dest[i] = a[i] - b[i]; - } -} - -void test_vsub_i16_u (uint16_t * dest, uint16_t * a, uint16_t * b) { - int i; - for (i=0; i<8; i++) { - dest[i] = a[i] - b[i]; - } -} - /* { dg-final { scan-assembler-times {vsub\.i16\tq[0-9]+, q[0-9]+, q[0-9]+} 2 } } */ +/* { dg-final { scan-assembler-times {vsub\.i8\tq[0-9]+, q[0-9]+, q[0-9]+} 2 } } */ -void test_vsub_i8 (int8_t * dest, int8_t * a, int8_t * b) { - int i; - for (i=0; i<16; i++) { - dest[i] = a[i] - b[i]; - } -} - -void test_vsub_i8_u (uint8_t * dest, uint8_t * a, uint8_t * b) { +void test_vsub_f32 (float * dest, float * a, float * b) { int i; - for (i=0; i<16; i++) { + for (i=0; i<4; i++) { dest[i] = a[i] - b[i]; } } +/* { dg-final { scan-assembler-times {vsub\.f32\tq[0-9]+, q[0-9]+, q[0-9]+} 1 } } */ -/* { dg-final { scan-assembler-times {vsub\.i8\tq[0-9]+, q[0-9]+, q[0-9]+} 2 } } */ -void test_vsub_f32 (float * dest, float * a, float * b) { +void test_vsub_f16 (__fp16 * dest, __fp16 * a, __fp16 * b) { int i; - for (i=0; i<4; i++) { + for (i=0; i<8; i++) { dest[i] = a[i] - b[i]; } } -/* { dg-final { scan-assembler-times {vsub\.f32\tq[0-9]+, q[0-9]+, q[0-9]+} 1 } } */ +/* { dg-final { scan-assembler-times {vsub\.f16\tq[0-9]+, q[0-9]+, q[0-9]+} 1 } } */ -- 2.7.4