diff options
author | H.J. Lu <hongjiu.lu@intel.com> | 2018-10-22 07:25:51 +0000 |
---|---|---|
committer | H.J. Lu <hjl@gcc.gnu.org> | 2018-10-22 00:25:51 -0700 |
commit | 26d50717b8fa7927e62f78092435db0e0c178035 (patch) | |
tree | af7c6f63613051c9ddfe2123f718f020e1674906 | |
parent | 0067ddcc0fca060a18243cec30d3d7f3931acbc3 (diff) | |
download | gcc-26d50717b8fa7927e62f78092435db0e0c178035.zip gcc-26d50717b8fa7927e62f78092435db0e0c178035.tar.gz gcc-26d50717b8fa7927e62f78092435db0e0c178035.tar.bz2 |
i386: Enable AVX512 memory broadcast for INT add
Many AVX512 vector operations can broadcast from a scalar memory source.
This patch enables memory broadcast for INT add operations.
gcc/
PR target/72782
* config/i386/sse.md (avx512bcst): Updated for V4SI, V2DI, V8SI,
V4DI, V16SI and V8DI.
(*sub<mode>3<mask_name>_bcst): New.
(*add<mode>3<mask_name>_bcst): Likewise.
gcc/testsuite/
PR target/72782
* gcc.target/i386/avx512f-add-di-zmm-1.c: New test.
* gcc.target/i386/avx512f-add-si-zmm-1.c: Likewise.
* gcc.target/i386/avx512f-add-si-zmm-2.c: Likewise.
* gcc.target/i386/avx512f-add-si-zmm-3.c: Likewise.
* gcc.target/i386/avx512f-add-si-zmm-4.c: Likewise.
* gcc.target/i386/avx512f-add-si-zmm-5.c: Likewise.
* gcc.target/i386/avx512f-add-si-zmm-6.c: Likewise.
* gcc.target/i386/avx512f-sub-di-zmm-1.c: Likewise.
* gcc.target/i386/avx512f-sub-si-zmm-1.c: Likewise.
* gcc.target/i386/avx512f-sub-si-zmm-2.c: Likewise.
* gcc.target/i386/avx512f-sub-si-zmm-3.c: Likewise.
* gcc.target/i386/avx512f-sub-si-zmm-4.c: Likewise.
* gcc.target/i386/avx512f-sub-si-zmm-5.c: Likewise.
* gcc.target/i386/avx512vl-add-si-xmm-1.c: Likewise.
* gcc.target/i386/avx512vl-add-si-ymm-1.c: Likewise.
* gcc.target/i386/avx512vl-sub-si-xmm-1.c: Likewise.
* gcc.target/i386/avx512vl-sub-si-ymm-1.c: Likewise.
From-SVN: r265368
20 files changed, 261 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 0d11aa8..308da78 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2018-10-22 H.J. Lu <hongjiu.lu@intel.com> + + PR target/72782 + * config/i386/sse.md (avx512bcst): Updated for V4SI, V2DI, V8SI, + V4DI, V16SI and V8DI. + (*sub<mode>3<mask_name>_bcst): New. + (*add<mode>3<mask_name>_bcst): Likewise. + 2018-10-21 H.J. Lu <hongjiu.lu@intel.com> PR target/72782 diff --git a/gcc/config/i386/sse.md b/gcc/config/i386/sse.md index 28cecbf..c831ae2 100644 --- a/gcc/config/i386/sse.md +++ b/gcc/config/i386/sse.md @@ -656,7 +656,10 @@ V16SF V8DF]) (define_mode_attr avx512bcst - [(V4SF "%{1to4%}") (V2DF "%{1to2%}") + [(V4SI "%{1to4%}") (V2DI "%{1to2%}") + (V8SI "%{1to8%}") (V4DI "%{1to4%}") + (V16SI "%{1to16%}") (V8DI "%{1to8%}") + (V4SF "%{1to4%}") (V2DF "%{1to2%}") (V8SF "%{1to8%}") (V4DF "%{1to4%}") (V16SF "%{1to16%}") (V8DF "%{1to8%}")]) @@ -10440,6 +10443,30 @@ (set_attr "prefix" "orig,vex") (set_attr "mode" "<sseinsnmode>")]) +(define_insn "*sub<mode>3_bcst" + [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v") + (minus:VI48_AVX512VL + (match_operand:VI48_AVX512VL 1 "register_operand" "v") + (vec_duplicate:VI48_AVX512VL + (match_operand:<ssescalarmode> 2 "memory_operand" "m"))))] + "TARGET_AVX512F && ix86_binary_operator_ok (MINUS, <MODE>mode, operands)" + "vpsub<ssemodesuffix>\t{%2<avx512bcst>, %1, %0|%0, %1, %2<avx512bcst>}" + [(set_attr "type" "sseiadd") + (set_attr "prefix" "evex") + (set_attr "mode" "<sseinsnmode>")]) + +(define_insn "*add<mode>3_bcst" + [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v") + (plus:VI48_AVX512VL + (vec_duplicate:VI48_AVX512VL + (match_operand:<ssescalarmode> 1 "memory_operand" "m")) + (match_operand:VI48_AVX512VL 2 "register_operand" "v")))] + "TARGET_AVX512F && ix86_binary_operator_ok (PLUS, <MODE>mode, operands)" + "vpadd<ssemodesuffix>\t{%1<avx512bcst>, %2, %0|%0, %2, %1<avx512bcst>}" + [(set_attr "type" "sseiadd") + (set_attr "prefix" "evex") + (set_attr "mode" "<sseinsnmode>")]) + (define_insn "*<plusminus_insn><mode>3_mask" [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v") (vec_merge:VI48_AVX512VL diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index dab4031..15e03fa 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,24 @@ +2018-10-22 H.J. Lu <hongjiu.lu@intel.com> + + PR target/72782 + * gcc.target/i386/avx512f-add-di-zmm-1.c: New test. + * gcc.target/i386/avx512f-add-si-zmm-1.c: Likewise. + * gcc.target/i386/avx512f-add-si-zmm-2.c: Likewise. + * gcc.target/i386/avx512f-add-si-zmm-3.c: Likewise. + * gcc.target/i386/avx512f-add-si-zmm-4.c: Likewise. + * gcc.target/i386/avx512f-add-si-zmm-5.c: Likewise. + * gcc.target/i386/avx512f-add-si-zmm-6.c: Likewise. + * gcc.target/i386/avx512f-sub-di-zmm-1.c: Likewise. + * gcc.target/i386/avx512f-sub-si-zmm-1.c: Likewise. + * gcc.target/i386/avx512f-sub-si-zmm-2.c: Likewise. + * gcc.target/i386/avx512f-sub-si-zmm-3.c: Likewise. + * gcc.target/i386/avx512f-sub-si-zmm-4.c: Likewise. + * gcc.target/i386/avx512f-sub-si-zmm-5.c: Likewise. + * gcc.target/i386/avx512vl-add-si-xmm-1.c: Likewise. + * gcc.target/i386/avx512vl-add-si-ymm-1.c: Likewise. + * gcc.target/i386/avx512vl-sub-si-xmm-1.c: Likewise. + * gcc.target/i386/avx512vl-sub-si-ymm-1.c: Likewise. + 2018-10-21 H.J. Lu <hongjiu.lu@intel.com> PR target/72782 diff --git a/gcc/testsuite/gcc.target/i386/avx512f-add-di-zmm-1.c b/gcc/testsuite/gcc.target/i386/avx512f-add-di-zmm-1.c new file mode 100644 index 0000000..eaf5093 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512f-add-di-zmm-1.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-mavx512f -O2" } */ +/* { dg-final { scan-assembler-times "vpaddq\[ \\t\]+\\(%(?:eax|rdi|edi)\\)\\\{1to\[1-8\]+\\\}, %zmm\[0-9\]+, %zmm0" 1 } } */ +/* { dg-final { scan-assembler-not "vpbroadcastq\[^\n\]*%zmm\[0-9\]+" } } */ + +#define type __m512i +#define vec 512 +#define op add +#define suffix epi64 +#define SCALAR long long + +#include "avx512-binop-1.h" diff --git a/gcc/testsuite/gcc.target/i386/avx512f-add-si-zmm-1.c b/gcc/testsuite/gcc.target/i386/avx512f-add-si-zmm-1.c new file mode 100644 index 0000000..bdb5a18 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512f-add-si-zmm-1.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-mavx512f -O2" } */ +/* { dg-final { scan-assembler-times "vpaddd\[ \\t\]+\\(%(?:eax|rdi|edi)\\)\\\{1to\[1-8\]+\\\}, %zmm\[0-9\]+, %zmm0" 1 } } */ +/* { dg-final { scan-assembler-not "vpbroadcastd\[^\n\]*%zmm\[0-9\]+" } } */ + +#define type __m512i +#define vec 512 +#define op add +#define suffix epi32 +#define SCALAR int + +#include "avx512-binop-1.h" diff --git a/gcc/testsuite/gcc.target/i386/avx512f-add-si-zmm-2.c b/gcc/testsuite/gcc.target/i386/avx512f-add-si-zmm-2.c new file mode 100644 index 0000000..de2148d --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512f-add-si-zmm-2.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-mavx512f -O2" } */ +/* { dg-final { scan-assembler-times "vpaddd\[ \\t\]+\\(%(?:eax|rdi|edi)\\)\\\{1to\[1-8\]+\\\}, %zmm\[0-9\]+, %zmm0" 1 } } */ +/* { dg-final { scan-assembler-not "vpbroadcastd\[^\n\]*%zmm\[0-9\]+" } } */ + +#define type __m512i +#define vec 512 +#define op add +#define suffix epi32 +#define SCALAR int + +#include "avx512-binop-2.h" diff --git a/gcc/testsuite/gcc.target/i386/avx512f-add-si-zmm-3.c b/gcc/testsuite/gcc.target/i386/avx512f-add-si-zmm-3.c new file mode 100644 index 0000000..b581f8a --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512f-add-si-zmm-3.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-mavx512f -O2" } */ +/* { dg-final { scan-assembler-times "vpbroadcastd\[^\n\]*%zmm\[0-9\]+" 1 } } */ +/* { dg-final { scan-assembler-times "vpaddd\[^\n\]*%zmm\[0-9\]+" 1 } } */ + +#define type __m512i +#define vec 512 +#define op add +#define suffix epi32 +#define SCALAR int + +#include "avx512-binop-3.h" diff --git a/gcc/testsuite/gcc.target/i386/avx512f-add-si-zmm-4.c b/gcc/testsuite/gcc.target/i386/avx512f-add-si-zmm-4.c new file mode 100644 index 0000000..04f199f --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512f-add-si-zmm-4.c @@ -0,0 +1,12 @@ +/* { dg-do compile { target { ! ia32 } } } */ +/* { dg-options "-mavx512f -O2" } */ +/* { dg-final { scan-assembler-times "vpbroadcastd\[^\n\]*%zmm\[0-9\]+" 1 } } */ +/* { dg-final { scan-assembler-times "vpaddd\[ \\t\]+%zmm\[0-9\]+, %zmm\[0-9\]+, %zmm0" 1 } } */ + +#define type __m512i +#define vec 512 +#define op add +#define suffix epi32 +#define SCALAR int + +#include "avx512-binop-4.h" diff --git a/gcc/testsuite/gcc.target/i386/avx512f-add-si-zmm-5.c b/gcc/testsuite/gcc.target/i386/avx512f-add-si-zmm-5.c new file mode 100644 index 0000000..983d390 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512f-add-si-zmm-5.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-mavx512f -O2" } */ +/* { dg-final { scan-assembler-times "vpaddd\[ \\t\]+\[^\n\]*\\\{1to\[1-8\]+\\\}, %zmm\[0-9\]+, %zmm0" 1 } } */ +/* { dg-final { scan-assembler-not "vpbroadcastd\[^\n\]*%zmm\[0-9\]+" } } */ + +#define type __m512i +#define vec 512 +#define op add +#define suffix epi32 +#define SCALAR int + +#include "avx512-binop-5.h" diff --git a/gcc/testsuite/gcc.target/i386/avx512f-add-si-zmm-6.c b/gcc/testsuite/gcc.target/i386/avx512f-add-si-zmm-6.c new file mode 100644 index 0000000..54dba2b --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512f-add-si-zmm-6.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-mavx512f -O2" } */ +/* { dg-final { scan-assembler-times "vpaddd\[ \\t\]+\[^\n\]*\\\{1to\[1-8\]+\\\}, %zmm\[0-9\]+, %zmm0" 1 } } */ +/* { dg-final { scan-assembler-not "vpbroadcastd\[^\n\]*%zmm\[0-9\]+" } } */ + +#define type __m512i +#define vec 512 +#define op add +#define suffix epi32 +#define SCALAR int + +#include "avx512-binop-6.h" diff --git a/gcc/testsuite/gcc.target/i386/avx512f-sub-di-zmm-1.c b/gcc/testsuite/gcc.target/i386/avx512f-sub-di-zmm-1.c new file mode 100644 index 0000000..771f23d --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512f-sub-di-zmm-1.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-mavx512f -O2" } */ +/* { dg-final { scan-assembler-times "vpsubq\[ \\t\]+\\(%(?:eax|rdi|edi)\\)\\\{1to\[1-8\]+\\\}, %zmm\[0-9\]+, %zmm0" 1 } } */ +/* { dg-final { scan-assembler-not "vpbroadcastq\[^\n\]*%zmm\[0-9\]+" } } */ + +#define type __m512i +#define vec 512 +#define op sub +#define suffix epi64 +#define SCALAR long long + +#include "avx512-binop-1.h" diff --git a/gcc/testsuite/gcc.target/i386/avx512f-sub-si-zmm-1.c b/gcc/testsuite/gcc.target/i386/avx512f-sub-si-zmm-1.c new file mode 100644 index 0000000..3e4897c --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512f-sub-si-zmm-1.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-mavx512f -O2" } */ +/* { dg-final { scan-assembler-times "vpsubd\[ \\t\]+\\(%(?:eax|rdi|edi)\\)\\\{1to\[1-8\]+\\\}, %zmm\[0-9\]+, %zmm0" 1 } } */ +/* { dg-final { scan-assembler-not "vpbroadcastd\[^\n\]*%zmm\[0-9\]+" } } */ + +#define type __m512i +#define vec 512 +#define op sub +#define suffix epi32 +#define SCALAR int + +#include "avx512-binop-1.h" diff --git a/gcc/testsuite/gcc.target/i386/avx512f-sub-si-zmm-2.c b/gcc/testsuite/gcc.target/i386/avx512f-sub-si-zmm-2.c new file mode 100644 index 0000000..090f3ff --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512f-sub-si-zmm-2.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-mavx512f -O2" } */ +/* { dg-final { scan-assembler-times "vpbroadcastd\[^\n\]*%zmm\[0-9\]+" 1 } } */ +/* { dg-final { scan-assembler-times "vpsubd\[^\n\]*%zmm\[0-9\]+" 1 } } */ + +#define type __m512i +#define vec 512 +#define op sub +#define suffix epi32 +#define SCALAR int + +#include "avx512-binop-2.h" diff --git a/gcc/testsuite/gcc.target/i386/avx512f-sub-si-zmm-3.c b/gcc/testsuite/gcc.target/i386/avx512f-sub-si-zmm-3.c new file mode 100644 index 0000000..1f75c88 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512f-sub-si-zmm-3.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-mavx512f -O2" } */ +/* { dg-final { scan-assembler-times "vpbroadcastd\[^\n\]*%zmm\[0-9\]+" 1 } } */ +/* { dg-final { scan-assembler-times "vpsubd\[^\n\]*%zmm\[0-9\]+" 1 } } */ + +#define type __m512i +#define vec 512 +#define op sub +#define suffix epi32 +#define SCALAR int + +#include "avx512-binop-3.h" diff --git a/gcc/testsuite/gcc.target/i386/avx512f-sub-si-zmm-4.c b/gcc/testsuite/gcc.target/i386/avx512f-sub-si-zmm-4.c new file mode 100644 index 0000000..0617a7b --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512f-sub-si-zmm-4.c @@ -0,0 +1,12 @@ +/* { dg-do compile { target { ! ia32 } } } */ +/* { dg-options "-mavx512f -O2" } */ +/* { dg-final { scan-assembler-times "vpbroadcastd\[^\n\]*%zmm\[0-9\]+" 1 } } */ +/* { dg-final { scan-assembler-times "vpsubd\[ \\t\]+%zmm\[0-9\]+, %zmm\[0-9\]+, %zmm0" 1 } } */ + +#define type __m512i +#define vec 512 +#define op sub +#define suffix epi32 +#define SCALAR int + +#include "avx512-binop-4.h" diff --git a/gcc/testsuite/gcc.target/i386/avx512f-sub-si-zmm-5.c b/gcc/testsuite/gcc.target/i386/avx512f-sub-si-zmm-5.c new file mode 100644 index 0000000..4e0c845 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512f-sub-si-zmm-5.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-mavx512f -O2" } */ +/* { dg-final { scan-assembler-times "vpsubd\[ \\t\]+\[^\n\]*\\\{1to\[1-8\]+\\\}, %zmm\[0-9\]+, %zmm0" 1 } } */ +/* { dg-final { scan-assembler-not "vpbroadcastd\[^\n\]*%zmm\[0-9\]+" } } */ + +#define type __m512i +#define vec 512 +#define op sub +#define suffix epi32 +#define SCALAR int + +#include "avx512-binop-5.h" diff --git a/gcc/testsuite/gcc.target/i386/avx512vl-add-si-xmm-1.c b/gcc/testsuite/gcc.target/i386/avx512vl-add-si-xmm-1.c new file mode 100644 index 0000000..bf57563 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512vl-add-si-xmm-1.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-mavx512vl -O2" } */ +/* { dg-final { scan-assembler-times "vpaddd\[ \\t\]+\\(%(?:eax|rdi|edi)\\)\\\{1to\[1-8\]+\\\}, %xmm\[0-9\]+, %xmm0" 1 } } */ +/* { dg-final { scan-assembler-not "vpbroadcastd\[^\n\]*%xmm\[0-9\]+" } } */ + +#define type __m128i +#define vec +#define op add +#define suffix epi32 +#define SCALAR int + +#include "avx512-binop-1.h" diff --git a/gcc/testsuite/gcc.target/i386/avx512vl-add-si-ymm-1.c b/gcc/testsuite/gcc.target/i386/avx512vl-add-si-ymm-1.c new file mode 100644 index 0000000..54bdbeb --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512vl-add-si-ymm-1.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-mavx512vl -O2" } */ +/* { dg-final { scan-assembler-times "vpaddd\[ \\t\]+\\(%(?:eax|rdi|edi)\\)\\\{1to\[1-8\]+\\\}, %ymm\[0-9\]+, %ymm0" 1 } } */ +/* { dg-final { scan-assembler-not "vpbroadcastd\[^\n\]*%ymm\[0-9\]+" } } */ + +#define type __m256i +#define vec 256 +#define op add +#define suffix epi32 +#define SCALAR int + +#include "avx512-binop-1.h" diff --git a/gcc/testsuite/gcc.target/i386/avx512vl-sub-si-xmm-1.c b/gcc/testsuite/gcc.target/i386/avx512vl-sub-si-xmm-1.c new file mode 100644 index 0000000..a29a236 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512vl-sub-si-xmm-1.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-mavx512vl -O2" } */ +/* { dg-final { scan-assembler-times "vpsubd\[ \\t\]+\\(%(?:eax|rdi|edi)\\)\\\{1to\[1-8\]+\\\}, %xmm\[0-9\]+, %xmm0" 1 } } */ +/* { dg-final { scan-assembler-not "vpbroadcastd\[^\n\]*%xmm\[0-9\]+" } } */ + +#define type __m128i +#define vec +#define op sub +#define suffix epi32 +#define SCALAR int + +#include "avx512-binop-1.h" diff --git a/gcc/testsuite/gcc.target/i386/avx512vl-sub-si-ymm-1.c b/gcc/testsuite/gcc.target/i386/avx512vl-sub-si-ymm-1.c new file mode 100644 index 0000000..3f248a3 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx512vl-sub-si-ymm-1.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-mavx512vl -O2" } */ +/* { dg-final { scan-assembler-times "vpsubd\[ \\t\]+\\(%(?:eax|rdi|edi)\\)\\\{1to\[1-8\]+\\\}, %ymm\[0-9\]+, %ymm0" 1 } } */ +/* { dg-final { scan-assembler-not "vpbroadcastd\[^\n\]*%ymm\[0-9\]+" } } */ + +#define type __m256i +#define vec 256 +#define op sub +#define suffix epi32 +#define SCALAR int + +#include "avx512-binop-1.h" |