]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
i386: Don't use AVX512F integral masks for V*TImode [PR94438]
authorJakub Jelinek <jakub@redhat.com>
Wed, 8 Apr 2020 16:24:12 +0000 (18:24 +0200)
committerJakub Jelinek <jakub@redhat.com>
Wed, 16 Sep 2020 16:57:34 +0000 (18:57 +0200)
The ix86_get_mask_mode hook uses int mask for 512-bit vectors or 128/256-bit
vectors with AVX512VL (that is correct), and only for V*[SD][IF]mode if not
AVX512BW (also correct), but with AVX512BW it would stop checking the
elem_size altogether and pretend the hw has masking support for V*TImode
etc., which it doesn't.  That can lead to various ICEs later on.

2020-04-08  Jakub Jelinek  <jakub@redhat.com>

PR target/94438
* config/i386/i386.c (ix86_get_mask_mode): Only use int mask for elem_size
1, 2, 4 and 8.

* gcc.target/i386/avx512bw-pr94438.c: New test.
* gcc.target/i386/avx512vlbw-pr94438.c: New test.

(cherry picked from commit 8bf5faa9c463f0d53ffe835ba03d4502edfb959d)

gcc/config/i386/i386.c
gcc/testsuite/gcc.target/i386/avx512bw-pr94438.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/avx512vlbw-pr94438.c [new file with mode: 0644]

index ae5046ee6a0a3311f23ca92be18c351fbfc8b37a..c6bc468e36bf07a650d1f8731ce1942acf7908e6 100644 (file)
@@ -50287,7 +50287,9 @@ ix86_get_mask_mode (poly_uint64 nunits, poly_uint64 vector_size)
   if ((TARGET_AVX512F && vector_size == 64)
       || (TARGET_AVX512VL && (vector_size == 32 || vector_size == 16)))
     {
-      if (elem_size == 4 || elem_size == 8 || TARGET_AVX512BW)
+      if (elem_size == 4
+         || elem_size == 8
+         || (TARGET_AVX512BW && (elem_size == 1 || elem_size == 2)))
        return smallest_int_mode_for_size (nunits);
     }
 
diff --git a/gcc/testsuite/gcc.target/i386/avx512bw-pr94438.c b/gcc/testsuite/gcc.target/i386/avx512bw-pr94438.c
new file mode 100644 (file)
index 0000000..9e56f28
--- /dev/null
@@ -0,0 +1,13 @@
+/* PR target/94438 */
+/* { dg-do compile { target int128 } } */
+/* { dg-options "-mavx512bw" } */
+
+typedef __attribute__ ((__vector_size__ (4 * sizeof (__int128)))) __int128 V;
+void bar (V);
+
+void
+foo (V w)
+{
+  V v = 0 <= (0 >= w);
+  bar (v);
+}
diff --git a/gcc/testsuite/gcc.target/i386/avx512vlbw-pr94438.c b/gcc/testsuite/gcc.target/i386/avx512vlbw-pr94438.c
new file mode 100644 (file)
index 0000000..a0c52e4
--- /dev/null
@@ -0,0 +1,13 @@
+/* PR target/94438 */
+/* { dg-do compile { target int128 } } */
+/* { dg-options "-mavx512bw -mavx512vl" } */
+
+typedef __attribute__ ((__vector_size__ (sizeof (__int128)))) __int128 V;
+void bar (V);
+
+void
+foo (V w)
+{
+  V v = 0 <= (0 >= w);
+  bar (v);
+}