From: liuhongt Date: Tue, 18 Aug 2020 07:06:01 +0000 (+0800) Subject: Adjust testcase. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=55290635d10ea3d18b0a45aa2e6f59405b8c1f54;p=gcc.git Adjust testcase. Rewriting testcase with cpp source file, then compare operator could be used directly for vector, this would avoid impact of vectorizer. gcc/testsuite/ChangeLog: PR target/96667 * gcc.target/i386/avx512bw-pr96246-1.c: Moved to... * g++.target/i386/avx512bw-pr96246-1.C: ...here. * gcc.target/i386/avx512bw-pr96246-2.c: Moved to... * g++.target/i386/avx512bw-pr96246-2.C: ...here. * gcc.target/i386/avx512vl-pr96246-1.c: Moved to... * g++.target/i386/avx512vl-pr96246-1.C: ...here. * gcc.target/i386/avx512vl-pr96246-2.c: Moved to... * g++.target/i386/avx512vl-pr96246-2.C: ...here. --- diff --git a/gcc/testsuite/g++.target/i386/avx512bw-pr96246-1.C b/gcc/testsuite/g++.target/i386/avx512bw-pr96246-1.C new file mode 100644 index 00000000000..eec844460f1 --- /dev/null +++ b/gcc/testsuite/g++.target/i386/avx512bw-pr96246-1.C @@ -0,0 +1,27 @@ +/* PR target/96246 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -std=c++14 -mavx512bw" } */ +/* { dg-final { scan-assembler-times "vpblendm\[bwdq\]\[\t \]" 4 } } */ +/* { dg-final { scan-assembler-times "vblendmp\[sd\]\[\t \]" 2 } } */ + +typedef char v64qi __attribute__((vector_size (64))); +typedef short v32hi __attribute__((vector_size (64))); +typedef int v16si __attribute__((vector_size (64))); +typedef long long v8di __attribute__((vector_size (64))); +typedef float v16sf __attribute__((vector_size (64))); +typedef double v8df __attribute__((vector_size (64))); + +#define COMPILE_TEST(vtype, num) \ + vtype \ + __attribute__ ((noipa)) \ + foo_##vtype (vtype a, vtype b, vtype c, vtype d) \ + { \ + return a > b ? c : d; \ + } + +COMPILE_TEST (v64qi, 64); +COMPILE_TEST (v32hi, 32); +COMPILE_TEST (v16si, 16); +COMPILE_TEST (v8di, 8); +COMPILE_TEST (v16sf, 16); +COMPILE_TEST (v8df, 8); diff --git a/gcc/testsuite/g++.target/i386/avx512bw-pr96246-2.C b/gcc/testsuite/g++.target/i386/avx512bw-pr96246-2.C new file mode 100644 index 00000000000..b96b7c7c932 --- /dev/null +++ b/gcc/testsuite/g++.target/i386/avx512bw-pr96246-2.C @@ -0,0 +1,37 @@ +/* PR target/96246 */ +/* { dg-do run } */ +/* { dg-require-effective-target avx512bw } */ +/* { dg-options "-O2 -std=c++14 -mavx512bw" } */ + +#include "avx512bw-pr96246-1.C" + +#define RUNTIME_TEST(vtype, num) \ + do \ + { \ + vtype a, b, c, d; \ + vtype res; \ + for (int i = 0; i != num; i++) \ + { \ + a[i] = i * 2; \ + b[i] = i * i - 5; \ + c[i] = 1; \ + d[i] = 0; \ + } \ + res = foo_##vtype (a, b, c, d); \ + for (int i = 0; i != num; i++) \ + if (res [i] != (a[i] > b[i] ? c[i] : d[i])) \ + __builtin_abort (); \ + } \ + while (0) + +int +main (void) +{ + RUNTIME_TEST (v64qi, 64); + RUNTIME_TEST (v32hi, 32); + RUNTIME_TEST (v16si, 16); + RUNTIME_TEST (v8di, 8); + RUNTIME_TEST (v16sf, 16); + RUNTIME_TEST (v8df, 8); + return 0; +} diff --git a/gcc/testsuite/g++.target/i386/avx512vl-pr96246-1.C b/gcc/testsuite/g++.target/i386/avx512vl-pr96246-1.C new file mode 100644 index 00000000000..66eb9d25f1e --- /dev/null +++ b/gcc/testsuite/g++.target/i386/avx512vl-pr96246-1.C @@ -0,0 +1,33 @@ +/* PR target/96246 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -std=c++14 -mavx512bw -mavx512vl" } */ +/* { dg-final { scan-assembler-times "vpblendm\[bwdq\]\[\t \]" 6 } } */ +/* { dg-final { scan-assembler-times "vblendmp\[sd\]\[\t \]" 3 } } */ + +typedef char v16qi __attribute__ ((vector_size (16))); +typedef char v32qi __attribute__ ((vector_size (32))); +typedef char v16hi __attribute__ ((vector_size (32))); +typedef int v4si __attribute__((vector_size (16))); +typedef int v8si __attribute__((vector_size (32))); +typedef long long v4di __attribute__((vector_size (32))); +typedef float v4sf __attribute__((vector_size (16))); +typedef float v8sf __attribute__((vector_size (32))); +typedef double v4df __attribute__((vector_size (32))); + +#define COMPILE_TEST(vtype, num) \ + vtype \ + __attribute__ ((noipa)) \ + foo_##vtype (vtype a, vtype b, vtype c, vtype d) \ + { \ + return a > b ? c : d; \ + } + +COMPILE_TEST (v16qi, 16); +COMPILE_TEST (v32qi, 32); +COMPILE_TEST (v16hi, 16); +COMPILE_TEST (v4si, 4); +COMPILE_TEST (v8si, 8); +COMPILE_TEST (v4sf, 4); +COMPILE_TEST (v8sf, 8); +COMPILE_TEST (v4di, 4); +COMPILE_TEST (v4df, 4); diff --git a/gcc/testsuite/g++.target/i386/avx512vl-pr96246-2.C b/gcc/testsuite/g++.target/i386/avx512vl-pr96246-2.C new file mode 100644 index 00000000000..9a16f0d2c9e --- /dev/null +++ b/gcc/testsuite/g++.target/i386/avx512vl-pr96246-2.C @@ -0,0 +1,41 @@ +/* PR target/96246 */ +/* { dg-do run } */ +/* { dg-require-effective-target avx512bw } */ +/* { dg-require-effective-target avx512vl } */ +/* { dg-options "-O2 -std=c++14 -mavx512bw -mavx512vl" } */ + +#include "avx512vl-pr96246-1.C" + +#define RUNTIME_TEST(vtype, num) \ + do \ + { \ + vtype a, b, c, d; \ + vtype res; \ + for (int i = 0; i != num; i++) \ + { \ + a[i] = i * 2; \ + b[i] = i * i - 5; \ + c[i] = 1; \ + d[i] = 0; \ + } \ + res = foo_##vtype (a, b, c, d); \ + for (int i = 0; i != num; i++) \ + if (res [i] != (a[i] > b[i] ? c[i] : d[i])) \ + __builtin_abort (); \ + } \ + while (0) + +int +main (void) +{ + RUNTIME_TEST (v16qi, 16); + RUNTIME_TEST (v32qi, 32); + RUNTIME_TEST (v16hi, 16); + RUNTIME_TEST (v4si, 4); + RUNTIME_TEST (v8si, 8); + RUNTIME_TEST (v4sf, 4); + RUNTIME_TEST (v8sf, 8); + RUNTIME_TEST (v4di, 4); + RUNTIME_TEST (v4df, 4); + return 0; +} diff --git a/gcc/testsuite/gcc.target/i386/avx512bw-pr96246-1.c b/gcc/testsuite/gcc.target/i386/avx512bw-pr96246-1.c deleted file mode 100644 index 2bfcc840a91..00000000000 --- a/gcc/testsuite/gcc.target/i386/avx512bw-pr96246-1.c +++ /dev/null @@ -1,30 +0,0 @@ -/* PR target/96246 */ -/* { dg-do compile } */ -/* { dg-options "-O2 -ftree-vectorize -mavx512bw" } */ -/* { dg-final { scan-assembler-times "vpblendm\[bwdq\]\[\t ]" 4 } } */ -/* { dg-final { scan-assembler-times "vblendmp\[sd\]\[\t ]" 2 } } */ - -typedef char v64qi __attribute__((vector_size (64))); -typedef short v32hi __attribute__((vector_size (64))); -typedef int v16si __attribute__((vector_size (64))); -typedef long long v8di __attribute__((vector_size (64))); -typedef float v16sf __attribute__((vector_size (64))); -typedef double v8df __attribute__((vector_size (64))); - -#define COMPILE_TEST(vtype, num) \ - vtype \ - __attribute__ ((noipa)) \ - foo_##vtype (vtype a, vtype b, vtype c, vtype d) \ - { \ - vtype e; \ - for (int i = 0; i != num; i++) \ - e[i] = a[i] > b[i] ? c[i] : d[i]; \ - return e; \ - } - -COMPILE_TEST (v64qi, 64); -COMPILE_TEST (v32hi, 32); -COMPILE_TEST (v16si, 16); -COMPILE_TEST (v8di, 8); -COMPILE_TEST (v16sf, 16); -COMPILE_TEST (v8df, 8); diff --git a/gcc/testsuite/gcc.target/i386/avx512bw-pr96246-2.c b/gcc/testsuite/gcc.target/i386/avx512bw-pr96246-2.c deleted file mode 100644 index 422fcfe4ea8..00000000000 --- a/gcc/testsuite/gcc.target/i386/avx512bw-pr96246-2.c +++ /dev/null @@ -1,47 +0,0 @@ -/* PR target/96246 */ -/* { dg-do run } */ -/* { dg-require-effective-target avx512bw } */ -/* { dg-options "-Ofast -mavx512bw" } */ - -#ifndef CHECK -#define CHECK "avx512f-helper.h" -#endif - -#include CHECK - -#ifndef TEST -#define TEST avx512bw_test -#endif - -#include "avx512bw-pr96246-1.c" - -#define RUNTIME_TEST(vtype, num) \ - do \ - { \ - vtype a, b, c, d; \ - vtype res; \ - for (int i = 0; i != num; i++) \ - { \ - a[i] = i * 2; \ - b[i] = i * i - 5; \ - c[i] = 1; \ - d[i] = 0; \ - } \ - res = foo_##vtype (a, b, c, d); \ - for (int i = 0; i != num; i++) \ - if (res [i] != (a[i] > b[i] ? c[i] : d[i])) \ - __builtin_abort (); \ - } \ - while (0) - -static void -__attribute__ ((optimize (0))) -TEST (void) -{ - RUNTIME_TEST (v64qi, 64); - RUNTIME_TEST (v32hi, 32); - RUNTIME_TEST (v16si, 16); - RUNTIME_TEST (v8di, 8); - RUNTIME_TEST (v16sf, 16); - RUNTIME_TEST (v8df, 8); -} diff --git a/gcc/testsuite/gcc.target/i386/avx512vl-pr96246-1.c b/gcc/testsuite/gcc.target/i386/avx512vl-pr96246-1.c deleted file mode 100644 index 95357d6fc84..00000000000 --- a/gcc/testsuite/gcc.target/i386/avx512vl-pr96246-1.c +++ /dev/null @@ -1,36 +0,0 @@ -/* PR target/96246 */ -/* { dg-do compile } */ -/* { dg-options "-O2 -ftree-vectorize -mavx512bw -mavx512vl" } */ -/* { dg-final { scan-assembler-times "vpblendm\[bwdq\]\[\t ]" 6 } } */ -/* { dg-final { scan-assembler-times "vblendmp\[sd\]\[\t ]" 3 } } */ - -typedef char v16qi __attribute__ ((vector_size (16))); -typedef char v32qi __attribute__ ((vector_size (32))); -typedef char v16hi __attribute__ ((vector_size (32))); -typedef int v4si __attribute__((vector_size (16))); -typedef int v8si __attribute__((vector_size (32))); -typedef long long v4di __attribute__((vector_size (32))); -typedef float v4sf __attribute__((vector_size (16))); -typedef float v8sf __attribute__((vector_size (32))); -typedef double v4df __attribute__((vector_size (32))); - -#define COMPILE_TEST(vtype, num) \ - vtype \ - __attribute__ ((noipa)) \ - foo_##vtype (vtype a, vtype b, vtype c, vtype d) \ - { \ - vtype e; \ - for (int i = 0; i != num; i++) \ - e[i] = a[i] > b[i] ? c[i] : d[i]; \ - return e; \ - } - -COMPILE_TEST (v16qi, 16); -COMPILE_TEST (v32qi, 32); -COMPILE_TEST (v16hi, 16); -COMPILE_TEST (v4si, 4); -COMPILE_TEST (v8si, 8); -COMPILE_TEST (v4sf, 4); -COMPILE_TEST (v8sf, 8); -COMPILE_TEST (v4di, 4); -COMPILE_TEST (v4df, 4); diff --git a/gcc/testsuite/gcc.target/i386/avx512vl-pr96246-2.c b/gcc/testsuite/gcc.target/i386/avx512vl-pr96246-2.c deleted file mode 100644 index d219f7c15ad..00000000000 --- a/gcc/testsuite/gcc.target/i386/avx512vl-pr96246-2.c +++ /dev/null @@ -1,51 +0,0 @@ -/* PR target/96246 */ -/* { dg-do run } */ -/* { dg-require-effective-target avx512bw } */ -/* { dg-require-effective-target avx512vl } */ -/* { dg-options "-Ofast -mavx512bw -mavx512vl" } */ - -#ifndef CHECK -#define CHECK "avx512f-helper.h" -#endif - -#include CHECK - -#ifndef TEST -#define TEST avx512bw_test -#endif - -#include "avx512vl-pr96246-1.c" - -#define RUNTIME_TEST(vtype, num) \ - do \ - { \ - vtype a, b, c, d; \ - vtype res; \ - for (int i = 0; i != num; i++) \ - { \ - a[i] = i * 2; \ - b[i] = i * i - 5; \ - c[i] = 1; \ - d[i] = 0; \ - } \ - res = foo_##vtype (a, b, c, d); \ - for (int i = 0; i != num; i++) \ - if (res [i] != (a[i] > b[i] ? c[i] : d[i])) \ - __builtin_abort (); \ - } \ - while (0) - -static void -__attribute__ ((optimize (0))) -TEST (void) -{ - RUNTIME_TEST (v16qi, 16); - RUNTIME_TEST (v32qi, 32); - RUNTIME_TEST (v16hi, 16); - RUNTIME_TEST (v4si, 4); - RUNTIME_TEST (v8si, 8); - RUNTIME_TEST (v4sf, 4); - RUNTIME_TEST (v8sf, 8); - RUNTIME_TEST (v4di, 4); - RUNTIME_TEST (v4df, 4); -}