tree-optimization/98308 - set vector type for mask of masked load
authorRichard Biener <rguenther@suse.de>
Mon, 4 Jan 2021 12:25:35 +0000 (13:25 +0100)
committerRichard Biener <rguenther@suse.de>
Mon, 4 Jan 2021 13:39:14 +0000 (14:39 +0100)
This makes sure to set the vector type on an invariant mask argument
for a masked load and SLP.

2021-01-04  Richard Biener  <rguenther@suse.de>

PR tree-optimization/98308
* tree-vect-stmts.c (vectorizable_load): Set invariant mask
SLP vectype.

* gcc.dg/vect/pr98308.c: New testcase.

gcc/testsuite/gcc.dg/vect/pr98308.c [new file with mode: 0644]
gcc/tree-vect-stmts.c

diff --git a/gcc/testsuite/gcc.dg/vect/pr98308.c b/gcc/testsuite/gcc.dg/vect/pr98308.c
new file mode 100644 (file)
index 0000000..7d717b1
--- /dev/null
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-O3" } */
+/* { dg-additional-options "-march=skylake-avx512" { target avx512f } } */
+
+extern unsigned long long int arr_86[];
+extern unsigned long long int arr_87[][15];
+
+void test(_Bool a, unsigned short c[][15], unsigned char d[])
+{
+  for (short h = 0; h < 10; h++)
+    for (char i = 0; i < 15; i += 2)
+      {
+       arr_86[0] = d[0];
+       arr_87[h][0] = a ? c[h][i] : 0;
+      }
+}
index 9e94675..54fb68b 100644 (file)
@@ -8563,6 +8563,17 @@ vectorizable_load (vec_info *vinfo,
 
   if (!vec_stmt) /* transformation not required.  */
     {
+      if (slp_node
+         && mask
+         && !vect_maybe_update_slp_op_vectype (SLP_TREE_CHILDREN (slp_node)[0],
+                                               mask_vectype))
+       {
+         if (dump_enabled_p ())
+           dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                            "incompatible vector types for invariants\n");
+         return false;
+       }
+
       if (!slp)
        STMT_VINFO_MEMORY_ACCESS_TYPE (stmt_info) = memory_access_type;