i386: Enable AVX512 memory broadcast for INT add
authorH.J. Lu <hongjiu.lu@intel.com>
Mon, 22 Oct 2018 07:25:51 +0000 (07:25 +0000)
committerH.J. Lu <hjl@gcc.gnu.org>
Mon, 22 Oct 2018 07:25:51 +0000 (00:25 -0700)
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:
gcc/ChangeLog
gcc/config/i386/sse.md
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/avx512f-add-di-zmm-1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/avx512f-add-si-zmm-1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/avx512f-add-si-zmm-2.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/avx512f-add-si-zmm-3.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/avx512f-add-si-zmm-4.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/avx512f-add-si-zmm-5.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/avx512f-add-si-zmm-6.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/avx512f-sub-di-zmm-1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/avx512f-sub-si-zmm-1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/avx512f-sub-si-zmm-2.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/avx512f-sub-si-zmm-3.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/avx512f-sub-si-zmm-4.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/avx512f-sub-si-zmm-5.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/avx512vl-add-si-xmm-1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/avx512vl-add-si-ymm-1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/avx512vl-sub-si-xmm-1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/avx512vl-sub-si-ymm-1.c [new file with mode: 0644]

index 0d11aa8e4ed3551714b02580d70642a685513904..308da786ebb649ecd7bc4be5148a29e280b92b67 100644 (file)
@@ -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
index 28cecbf9a091a79fa97247e7e102f92bcf4600a1..c831ae2d465e5f4b0255577728d11125ac7b25de 100644 (file)
    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%}")])
 
    (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
index dab4031dcd8c9215e0bfdfba0b2556c1409a9942..15e03fab46a9c3a0711ef462fe1f3b748da445ce 100644 (file)
@@ -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 (file)
index 0000000..eaf5093
--- /dev/null
@@ -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 (file)
index 0000000..bdb5a18
--- /dev/null
@@ -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 (file)
index 0000000..de2148d
--- /dev/null
@@ -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 (file)
index 0000000..b581f8a
--- /dev/null
@@ -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 (file)
index 0000000..04f199f
--- /dev/null
@@ -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 (file)
index 0000000..983d390
--- /dev/null
@@ -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 (file)
index 0000000..54dba2b
--- /dev/null
@@ -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 (file)
index 0000000..771f23d
--- /dev/null
@@ -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 (file)
index 0000000..3e4897c
--- /dev/null
@@ -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 (file)
index 0000000..090f3ff
--- /dev/null
@@ -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 (file)
index 0000000..1f75c88
--- /dev/null
@@ -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 (file)
index 0000000..0617a7b
--- /dev/null
@@ -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 (file)
index 0000000..4e0c845
--- /dev/null
@@ -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 (file)
index 0000000..bf57563
--- /dev/null
@@ -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 (file)
index 0000000..54bdbeb
--- /dev/null
@@ -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 (file)
index 0000000..a29a236
--- /dev/null
@@ -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 (file)
index 0000000..3f248a3
--- /dev/null
@@ -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"