i386: Enable AVX512 memory broadcast for INT andnot
authorH.J. Lu <hongjiu.lu@intel.com>
Mon, 22 Oct 2018 07:35:48 +0000 (07:35 +0000)
committerH.J. Lu <hjl@gcc.gnu.org>
Mon, 22 Oct 2018 07:35:48 +0000 (00:35 -0700)
Many AVX512 vector operations can broadcast from a scalar memory source.
This patch enables memory broadcast for INT andnot operations.

gcc/

PR target/72782
* config/i386/sse.md (*andnot<mode>3_bcst): New.

gcc/testsuite/

PR target/72782
* gcc.target/i386/avx512f-andn-di-zmm-1.c: New test.
* gcc.target/i386/avx512f-andn-si-zmm-1.c: Likewise.
* gcc.target/i386/avx512f-andn-si-zmm-2.c: Likewise.
* gcc.target/i386/avx512f-andn-si-zmm-3.c: Likewise.
* gcc.target/i386/avx512f-andn-si-zmm-4.c: Likewise.
* gcc.target/i386/avx512f-andn-si-zmm-5.c: Likewise.
* gcc.target/i386/avx512vl-andn-si-xmm-1.c: Likewise.
* gcc.target/i386/avx512vl-andn-si-ymm-1.c: Likewise.

From-SVN: r265370

gcc/ChangeLog
gcc/config/i386/sse.md
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/avx512f-andn-di-zmm-1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/avx512f-andn-si-zmm-1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/avx512f-andn-si-zmm-2.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/avx512f-andn-si-zmm-3.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/avx512f-andn-si-zmm-4.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/avx512f-andn-si-zmm-5.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/avx512vl-andn-si-xmm-1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/avx512vl-andn-si-ymm-1.c [new file with mode: 0644]

index 9b735458d7c667e178eb586e2963a14ceada77d9..7b1a98b8fb4825c47afebeb2dd5c640006db1f0c 100644 (file)
@@ -1,3 +1,8 @@
+2018-10-22  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR target/72782
+       * config/i386/sse.md (*andnot<mode>3_bcst): New.
+
 2018-10-22  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR target/72782
index e991da96aeea09167412d86b6ae763153366d494..ee73e1fdf80b147202b46186697344bc20c4be9d 100644 (file)
              ]
              (const_string "<sseinsnmode>")))])
 
+(define_insn "*andnot<mode>3_bcst"
+  [(set (match_operand:VI 0 "register_operand" "=v")
+       (and:VI
+         (not:VI48_AVX512VL
+            (match_operand:VI48_AVX512VL 1 "register_operand" "v"))
+         (vec_duplicate:VI48_AVX512VL
+           (match_operand:<ssescalarmode> 2 "memory_operand" "m"))))]
+  "TARGET_AVX512F"
+  "vpandn<ssemodesuffix>\t{%2<avx512bcst>, %1, %0|%0, %1, %2<avx512bcst>}"
+  [(set_attr "type" "sselog")
+   (set_attr "prefix" "evex")
+   (set_attr "mode" "<sseinsnmode>")])
+
 (define_insn "*andnot<mode>3_mask"
   [(set (match_operand:VI48_AVX512VL 0 "register_operand" "=v")
        (vec_merge:VI48_AVX512VL
index 43b0ab56ec19c11da3fffc31336a0e6f57f539eb..27d1ab98718636bd5fd17c634dd7eaa9843cc479 100644 (file)
@@ -1,3 +1,15 @@
+2018-10-22  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR target/72782
+       * gcc.target/i386/avx512f-andn-di-zmm-1.c: New test.
+       * gcc.target/i386/avx512f-andn-si-zmm-1.c: Likewise.
+       * gcc.target/i386/avx512f-andn-si-zmm-2.c: Likewise.
+       * gcc.target/i386/avx512f-andn-si-zmm-3.c: Likewise.
+       * gcc.target/i386/avx512f-andn-si-zmm-4.c: Likewise.
+       * gcc.target/i386/avx512f-andn-si-zmm-5.c: Likewise.
+       * gcc.target/i386/avx512vl-andn-si-xmm-1.c: Likewise.
+       * gcc.target/i386/avx512vl-andn-si-ymm-1.c: Likewise.
+
 2018-10-22  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR target/72782
diff --git a/gcc/testsuite/gcc.target/i386/avx512f-andn-di-zmm-1.c b/gcc/testsuite/gcc.target/i386/avx512f-andn-di-zmm-1.c
new file mode 100644 (file)
index 0000000..1450d3c
--- /dev/null
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx512f -O2" } */
+/* { dg-final { scan-assembler-times "vpandnq\[ \\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 andnot
+#define suffix epi64
+#define SCALAR long long
+
+#include "avx512-binop-1.h"
diff --git a/gcc/testsuite/gcc.target/i386/avx512f-andn-si-zmm-1.c b/gcc/testsuite/gcc.target/i386/avx512f-andn-si-zmm-1.c
new file mode 100644 (file)
index 0000000..c9d8a82
--- /dev/null
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx512f -O2" } */
+/* { dg-final { scan-assembler-times "vpandnd\[ \\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 andnot
+#define suffix epi32
+#define SCALAR int
+
+#include "avx512-binop-1.h"
diff --git a/gcc/testsuite/gcc.target/i386/avx512f-andn-si-zmm-2.c b/gcc/testsuite/gcc.target/i386/avx512f-andn-si-zmm-2.c
new file mode 100644 (file)
index 0000000..a9608ca
--- /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 "vpandnd\[^\n\]*%zmm\[0-9\]+" 1 } } */
+
+#define type __m512i
+#define vec 512
+#define op andnot
+#define suffix epi32
+#define SCALAR int
+
+#include "avx512-binop-2.h"
diff --git a/gcc/testsuite/gcc.target/i386/avx512f-andn-si-zmm-3.c b/gcc/testsuite/gcc.target/i386/avx512f-andn-si-zmm-3.c
new file mode 100644 (file)
index 0000000..71751fc
--- /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 "vpandnd\[^\n\]*%zmm\[0-9\]+" 1 } } */
+
+#define type __m512i
+#define vec 512
+#define op andnot
+#define suffix epi32
+#define SCALAR int
+
+#include "avx512-binop-3.h"
diff --git a/gcc/testsuite/gcc.target/i386/avx512f-andn-si-zmm-4.c b/gcc/testsuite/gcc.target/i386/avx512f-andn-si-zmm-4.c
new file mode 100644 (file)
index 0000000..d74c373
--- /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 "vpandnd\[ \\t\]+%zmm\[0-9\]+, %zmm\[0-9\]+, %zmm0" 1 } } */
+
+#define type __m512i
+#define vec 512
+#define op andnot
+#define suffix epi32
+#define SCALAR int
+
+#include "avx512-binop-4.h"
diff --git a/gcc/testsuite/gcc.target/i386/avx512f-andn-si-zmm-5.c b/gcc/testsuite/gcc.target/i386/avx512f-andn-si-zmm-5.c
new file mode 100644 (file)
index 0000000..8211815
--- /dev/null
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx512f -O2" } */
+/* { dg-final { scan-assembler-times "vpandnd\[ \\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 andnot
+#define suffix epi32
+#define SCALAR int
+
+#include "avx512-binop-5.h"
diff --git a/gcc/testsuite/gcc.target/i386/avx512vl-andn-si-xmm-1.c b/gcc/testsuite/gcc.target/i386/avx512vl-andn-si-xmm-1.c
new file mode 100644 (file)
index 0000000..0b084ae
--- /dev/null
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx512vl -O2" } */
+/* { dg-final { scan-assembler-times "vpandnd\[ \\t\]+\\(%(?:eax|rdi|edi)\\)\\\{1to\[1-8\]+\\\}, %xmm\[0-9\]+, %xmm0" 1 } } */
+/* { dg-final { scan-assembler-not "vpbroadcastd\[^\n\]*%xmm\[0-9\]+" } } */
+
+#include <immintrin.h>
+
+__m128i
+foo (__m128i x, int *f)
+{
+  return (__m128i) (~(__v4su) x & (__v4su) _mm_set1_epi32 (*f));
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx512vl-andn-si-ymm-1.c b/gcc/testsuite/gcc.target/i386/avx512vl-andn-si-ymm-1.c
new file mode 100644 (file)
index 0000000..cd27b40
--- /dev/null
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx512vl -O2" } */
+/* { dg-final { scan-assembler-times "vpandnd\[ \\t\]+\\(%(?:eax|rdi|edi)\\)\\\{1to\[1-8\]+\\\}, %ymm\[0-9\]+, %ymm0" 1 } } */
+/* { dg-final { scan-assembler-not "vpbroadcastd\[^\n\]*%ymm\[0-9\]+" } } */
+
+#include <immintrin.h>
+
+__m256i
+foo (__m256i x, int *f)
+{
+  return (__m256i) (~(__v8su) x & (__v8su) _mm256_set1_epi32 (*f));
+}