From: hjl Date: Tue, 18 Oct 2011 15:41:27 +0000 (+0000) Subject: Add some tests for AVX2 vectorizer. X-Git-Tag: upstream/4.9.2~16966 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a257850007b8444126c4f4f92a10081e5d1b17ab;p=platform%2Fupstream%2Flinaro-gcc.git Add some tests for AVX2 vectorizer. 2011-10-18 Kirill Yukhin * gcc.target/i386/avx2-vpop-check.h: New header. * gcc.target/i386/avx2-vpaddd-3.c: New test. * gcc.target/i386/avx2-vpaddw-3.c: Ditto. * gcc.target/i386/avx2-vpaddb-3.c: Ditto. * gcc.target/i386/avx2-vpaddq-3.c: Ditto. * gcc.target/i386/avx2-vpand-3.c: Ditto. * gcc.target/i386/avx2-vpmulld-3.c: Ditto. * gcc.target/i386/avx2-vpmullw-3.c: Ditto. * gcc.target/i386/avx2-vpsrad-3.c: Ditto. * gcc.target/i386/avx2-vpsraw-3.c: Ditto. * gcc.target/i386/avx2-vpsrld-3.c: Ditto. * gcc.target/i386/avx2-vpsrlw-3.c: Ditto. * gcc.target/i386/avx2-vpsubb-3.c: Ditto. * gcc.target/i386/avx2-vpsubd-3.c: Ditto. * gcc.target/i386/avx2-vpsubq-3.c: Ditto. * gcc.target/i386/avx2-vpsubw-3.c: Ditto. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@180155 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d44d2c5..ff6cc27 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,22 @@ +2011-10-18 Kirill Yukhin + + * gcc.target/i386/avx2-vpop-check.h: New header. + * gcc.target/i386/avx2-vpaddd-3.c: New test. + * gcc.target/i386/avx2-vpaddw-3.c: Ditto. + * gcc.target/i386/avx2-vpaddb-3.c: Ditto. + * gcc.target/i386/avx2-vpaddq-3.c: Ditto. + * gcc.target/i386/avx2-vpand-3.c: Ditto. + * gcc.target/i386/avx2-vpmulld-3.c: Ditto. + * gcc.target/i386/avx2-vpmullw-3.c: Ditto. + * gcc.target/i386/avx2-vpsrad-3.c: Ditto. + * gcc.target/i386/avx2-vpsraw-3.c: Ditto. + * gcc.target/i386/avx2-vpsrld-3.c: Ditto. + * gcc.target/i386/avx2-vpsrlw-3.c: Ditto. + * gcc.target/i386/avx2-vpsubb-3.c: Ditto. + * gcc.target/i386/avx2-vpsubd-3.c: Ditto. + * gcc.target/i386/avx2-vpsubq-3.c: Ditto. + * gcc.target/i386/avx2-vpsubw-3.c: Ditto. + 2011-10-18 Mikael Morin PR fortran/50420 diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpaddb-3.c b/gcc/testsuite/gcc.target/i386/avx2-vpaddb-3.c new file mode 100644 index 0000000..238f020 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx2-vpaddb-3.c @@ -0,0 +1,12 @@ +/* { dg-do run } */ +/* { dg-options "-mavx2 -O2 -ftree-vectorize -save-temps" } */ +/* { dg-require-effective-target avx2 } */ + + +#define TYPE char +#define BIN_OP(a, b) ((a) + (b)) + +#include "avx2-vpop-check.h" + +/* { dg-final { scan-assembler-times "vpaddb\[ \\t\]+\[^\n\]*%ymm\[0-9\]" 1 } } */ +/* { dg-final { cleanup-saved-temps } } */ diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpaddd-3.c b/gcc/testsuite/gcc.target/i386/avx2-vpaddd-3.c new file mode 100644 index 0000000..c57ef8f --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx2-vpaddd-3.c @@ -0,0 +1,12 @@ +/* { dg-do run } */ +/* { dg-options "-mavx2 -O2 -ftree-vectorize -save-temps" } */ +/* { dg-require-effective-target avx2 } */ + + +#define TYPE int +#define BIN_OP(a, b) ((a) + (b)) + +#include "avx2-vpop-check.h" + +/* { dg-final { scan-assembler-times "vpaddd\[ \\t\]+\[^\n\]*%ymm\[0-9\]" 1 } } */ +/* { dg-final { cleanup-saved-temps } } */ diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpaddq-3.c b/gcc/testsuite/gcc.target/i386/avx2-vpaddq-3.c new file mode 100644 index 0000000..801bd39 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx2-vpaddq-3.c @@ -0,0 +1,12 @@ +/* { dg-do run } */ +/* { dg-options "-mavx2 -O2 -ftree-vectorize -save-temps" } */ +/* { dg-require-effective-target avx2 } */ + + +#define TYPE long long int +#define BIN_OP(a, b) ((a) + (b)) + +#include "avx2-vpop-check.h" + +/* { dg-final { scan-assembler-times "vpaddq\[ \\t\]+\[^\n\]*%ymm\[0-9\]" 1 } } */ +/* { dg-final { cleanup-saved-temps } } */ diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpaddw-3.c b/gcc/testsuite/gcc.target/i386/avx2-vpaddw-3.c new file mode 100644 index 0000000..facee9f --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx2-vpaddw-3.c @@ -0,0 +1,12 @@ +/* { dg-do run } */ +/* { dg-options "-mavx2 -O2 -ftree-vectorize -save-temps" } */ +/* { dg-require-effective-target avx2 } */ + + +#define TYPE short +#define BIN_OP(a, b) ((a) + (b)) + +#include "avx2-vpop-check.h" + +/* { dg-final { scan-assembler-times "vpaddw\[ \\t\]+\[^\n\]*%ymm\[0-9\]" 1 } } */ +/* { dg-final { cleanup-saved-temps } } */ diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpand-3.c b/gcc/testsuite/gcc.target/i386/avx2-vpand-3.c new file mode 100644 index 0000000..67ca4a7 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx2-vpand-3.c @@ -0,0 +1,12 @@ +/* { dg-do run } */ +/* { dg-options "-mavx2 -O2 -ftree-vectorize -save-temps" } */ +/* { dg-require-effective-target avx2 } */ + + +#define TYPE unsigned +#define BIN_OP(a, b) ((a) & (b)) + +#include "avx2-vpop-check.h" + +/* { dg-final { scan-assembler-times "vpand\[ \\t\]+\[^\n\]*%ymm\[0-9\]" 1 } } */ +/* { dg-final { cleanup-saved-temps } } */ diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpmulld-3.c b/gcc/testsuite/gcc.target/i386/avx2-vpmulld-3.c new file mode 100644 index 0000000..b2d539b --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx2-vpmulld-3.c @@ -0,0 +1,12 @@ +/* { dg-do run } */ +/* { dg-options "-mavx2 -O2 -ftree-vectorize -save-temps" } */ +/* { dg-require-effective-target avx2 } */ + + +#define TYPE int +#define BIN_OP(a, b) ((a) * (b)) + +#include "avx2-vpop-check.h" + +/* { dg-final { scan-assembler-times "vpmulld\[ \\t\]+\[^\n\]*%ymm\[0-9\]" 1 } } */ +/* { dg-final { cleanup-saved-temps } } */ diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpmullw-3.c b/gcc/testsuite/gcc.target/i386/avx2-vpmullw-3.c new file mode 100644 index 0000000..46d173f --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx2-vpmullw-3.c @@ -0,0 +1,12 @@ +/* { dg-do run } */ +/* { dg-options "-mavx2 -O2 -ftree-vectorize -save-temps" } */ +/* { dg-require-effective-target avx2 } */ + + +#define TYPE short +#define BIN_OP(a, b) ((a) * (b)) + +#include "avx2-vpop-check.h" + +/* { dg-final { scan-assembler-times "vpmullw\[ \\t\]+\[^\n\]*%ymm\[0-9\]" 1 } } */ +/* { dg-final { cleanup-saved-temps } } */ diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpop-check.h b/gcc/testsuite/gcc.target/i386/avx2-vpop-check.h new file mode 100644 index 0000000..143b54d --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx2-vpop-check.h @@ -0,0 +1,53 @@ +#include "avx2-check.h" + +#define SIZE 256 + +TYPE a[SIZE]; +TYPE b[SIZE]; +TYPE c[SIZE]; +volatile TYPE c_ref[SIZE]; + +__attribute__ ((__noinline__)) +void +gen_pop () +{ + int i; + for (i = 0; i < SIZE; ++i) +#ifdef BIN_OP + c[i] = BIN_OP (a[i], b[i]); +#else /* Must be UN_OP */ + c[i] = UN_OP (a[i]); +#endif /* BIN_OP */ +} + +void +check_pop () +{ + int i; + for (i = 0; i < SIZE; ++i) +#ifdef BIN_OP + c_ref[i] = BIN_OP (a[i], b[i]); +#else /* Must be UN_OP */ + c_ref[i] = UN_OP (a[i]); +#endif /* BIN_OP */ +} + +void static +avx2_test (void) +{ + int i, j; + for (i = 0; i < 4; ++i ) + { + for ( j = 0; j < SIZE; ++j ) + { + a[i] = i * i + i; + b[i] = i * i * i; + } + + gen_pop (); + check_pop (); + + if (memcmp (c, c_ref, SIZE * sizeof (TYPE))) + abort(); + } +} diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsrad-3.c b/gcc/testsuite/gcc.target/i386/avx2-vpsrad-3.c new file mode 100644 index 0000000..97affb4 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx2-vpsrad-3.c @@ -0,0 +1,12 @@ +/* { dg-do run } */ +/* { dg-options "-mavx2 -O2 -ftree-vectorize -save-temps" } */ +/* { dg-require-effective-target avx2 } */ + + +#define TYPE unsigned +#define UN_OP(a) ((a) >> (5)) + +#include "avx2-vpop-check.h" + +/* { dg-final { scan-assembler-times "vpsrld\[ \\t\]+\[^\n\]*%ymm\[0-9\]" 1 } } */ +/* { dg-final { cleanup-saved-temps } } */ diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsraw-3.c b/gcc/testsuite/gcc.target/i386/avx2-vpsraw-3.c new file mode 100644 index 0000000..e711256 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx2-vpsraw-3.c @@ -0,0 +1,12 @@ +/* { dg-do run } */ +/* { dg-options "-mavx2 -O2 -ftree-vectorize -save-temps" } */ +/* { dg-require-effective-target avx2 } */ + + +#define TYPE short +#define UN_OP(a) ((a) >> (5)) + +#include "avx2-vpop-check.h" + +/* { dg-final { scan-assembler-times "vpsraw\[ \\t\]+\[^\n\]*%ymm\[0-9\]" 1 } } */ +/* { dg-final { cleanup-saved-temps } } */ diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsrld-3.c b/gcc/testsuite/gcc.target/i386/avx2-vpsrld-3.c new file mode 100644 index 0000000..97affb4 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx2-vpsrld-3.c @@ -0,0 +1,12 @@ +/* { dg-do run } */ +/* { dg-options "-mavx2 -O2 -ftree-vectorize -save-temps" } */ +/* { dg-require-effective-target avx2 } */ + + +#define TYPE unsigned +#define UN_OP(a) ((a) >> (5)) + +#include "avx2-vpop-check.h" + +/* { dg-final { scan-assembler-times "vpsrld\[ \\t\]+\[^\n\]*%ymm\[0-9\]" 1 } } */ +/* { dg-final { cleanup-saved-temps } } */ diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsrlw-3.c b/gcc/testsuite/gcc.target/i386/avx2-vpsrlw-3.c new file mode 100644 index 0000000..67f3afc --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx2-vpsrlw-3.c @@ -0,0 +1,12 @@ +/* { dg-do run } */ +/* { dg-options "-mavx2 -O2 -ftree-vectorize -save-temps" } */ +/* { dg-require-effective-target avx2 } */ + + +#define TYPE unsigned short +#define UN_OP(a) ((a) >> (5)) + +#include "avx2-vpop-check.h" + +/* { dg-final { scan-assembler-times "vpsrlw\[ \\t\]+\[^\n\]*%ymm\[0-9\]" 1 } } */ +/* { dg-final { cleanup-saved-temps } } */ diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsubb-3.c b/gcc/testsuite/gcc.target/i386/avx2-vpsubb-3.c new file mode 100644 index 0000000..843128b --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx2-vpsubb-3.c @@ -0,0 +1,12 @@ +/* { dg-do run } */ +/* { dg-options "-mavx2 -O2 -ftree-vectorize -save-temps" } */ +/* { dg-require-effective-target avx2 } */ + + +#define TYPE char +#define BIN_OP(a, b) ((a) - (b)) + +#include "avx2-vpop-check.h" + +/* { dg-final { scan-assembler-times "vpsubb\[ \\t\]+\[^\n\]*%ymm\[0-9\]" 1 } } */ +/* { dg-final { cleanup-saved-temps } } */ diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsubd-3.c b/gcc/testsuite/gcc.target/i386/avx2-vpsubd-3.c new file mode 100644 index 0000000..f8f399f --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx2-vpsubd-3.c @@ -0,0 +1,12 @@ +/* { dg-do run } */ +/* { dg-options "-mavx2 -O2 -ftree-vectorize -save-temps" } */ +/* { dg-require-effective-target avx2 } */ + + +#define TYPE int +#define BIN_OP(a, b) ((a) - (b)) + +#include "avx2-vpop-check.h" + +/* { dg-final { scan-assembler-times "vpsubd\[ \\t\]+\[^\n\]*%ymm\[0-9\]" 1 } } */ +/* { dg-final { cleanup-saved-temps } } */ diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsubq-3.c b/gcc/testsuite/gcc.target/i386/avx2-vpsubq-3.c new file mode 100644 index 0000000..0a23a28 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx2-vpsubq-3.c @@ -0,0 +1,12 @@ +/* { dg-do run } */ +/* { dg-options "-mavx2 -O2 -ftree-vectorize -save-temps" } */ +/* { dg-require-effective-target avx2 } */ + + +#define TYPE long long int +#define BIN_OP(a, b) ((a) - (b)) + +#include "avx2-vpop-check.h" + +/* { dg-final { scan-assembler-times "vpsubq\[ \\t\]+\[^\n\]*%ymm\[0-9\]" 1 } } */ +/* { dg-final { cleanup-saved-temps } } */ diff --git a/gcc/testsuite/gcc.target/i386/avx2-vpsubw-3.c b/gcc/testsuite/gcc.target/i386/avx2-vpsubw-3.c new file mode 100644 index 0000000..1cb90b5 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx2-vpsubw-3.c @@ -0,0 +1,12 @@ +/* { dg-do run } */ +/* { dg-options "-mavx2 -O2 -ftree-vectorize -save-temps" } */ +/* { dg-require-effective-target avx2 } */ + + +#define TYPE short +#define BIN_OP(a, b) ((a) - (b)) + +#include "avx2-vpop-check.h" + +/* { dg-final { scan-assembler-times "vpsubw\[ \\t\]+\[^\n\]*%ymm\[0-9\]" 1 } } */ +/* { dg-final { cleanup-saved-temps } } */