]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Split mask checking out of vectorizable_mask_load_store
authorrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 3 Jan 2018 21:47:03 +0000 (21:47 +0000)
committerrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 3 Jan 2018 21:47:03 +0000 (21:47 +0000)
This patch splits the mask argument checking out of
vectorizable_mask_load_store, so that a later patch can use it in both
vectorizable_load and vectorizable_store.  It also adds dump messages
for false returns.  This is mostly useful for the TYPE_VECTOR_SUBPARTS
check, which can fail if pattern recognition didn't convert the mask
properly.

2018-01-03  Richard Sandiford  <richard.sandiford@linaro.org>

gcc/
* tree-vect-stmts.c (vect_check_load_store_mask): New function,
split out from...
(vectorizable_mask_load_store): ...here.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@256212 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/tree-vect-stmts.c

index be6d5e15ac453cabc1ee6505a1b83f07aea80290..86320f716e49c0b39a672e262494a82650d2aa26 100644 (file)
@@ -1,3 +1,9 @@
+2018-01-03  Richard Sandiford  <richard.sandiford@linaro.org>
+
+       * tree-vect-stmts.c (vect_check_load_store_mask): New function,
+       split out from...
+       (vectorizable_mask_load_store): ...here.
+
 2018-01-03  Richard Sandiford  <richard.sandiford@linaro.org>
 
        * tree-vectorizer.h (vec_load_store_type): Moved from tree-vec-stmts.c
index cdca95acb507e6f230c3cb070881e4837df2aec3..c493eb54b4b211487de2e8576ccaca08f7dbbe26 100644 (file)
@@ -2024,6 +2024,74 @@ get_load_store_type (gimple *stmt, tree vectype, bool slp,
   return true;
 }
 
+/* Return true if boolean argument MASK is suitable for vectorizing
+   conditional load or store STMT.  When returning true, store the
+   type of the vectorized mask in *MASK_VECTYPE_OUT.  */
+
+static bool
+vect_check_load_store_mask (gimple *stmt, tree mask, tree *mask_vectype_out)
+{
+  if (!VECT_SCALAR_BOOLEAN_TYPE_P (TREE_TYPE (mask)))
+    {
+      if (dump_enabled_p ())
+       dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                        "mask argument is not a boolean.\n");
+      return false;
+    }
+
+  if (TREE_CODE (mask) != SSA_NAME)
+    {
+      if (dump_enabled_p ())
+       dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                        "mask argument is not an SSA name.\n");
+      return false;
+    }
+
+  stmt_vec_info stmt_info = vinfo_for_stmt (stmt);
+  gimple *def_stmt;
+  enum vect_def_type dt;
+  tree mask_vectype;
+  if (!vect_is_simple_use (mask, stmt_info->vinfo, &def_stmt, &dt,
+                          &mask_vectype))
+    {
+      if (dump_enabled_p ())
+       dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                        "mask use not simple.\n");
+      return false;
+    }
+
+  tree vectype = STMT_VINFO_VECTYPE (stmt_info);
+  if (!mask_vectype)
+    mask_vectype = get_mask_type_for_scalar_type (TREE_TYPE (vectype));
+
+  if (!mask_vectype || !VECTOR_BOOLEAN_TYPE_P (mask_vectype))
+    {
+      if (dump_enabled_p ())
+       dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                        "could not find an appropriate vector mask type.\n");
+      return false;
+    }
+
+  if (maybe_ne (TYPE_VECTOR_SUBPARTS (mask_vectype),
+               TYPE_VECTOR_SUBPARTS (vectype)))
+    {
+      if (dump_enabled_p ())
+       {
+         dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                          "vector mask type ");
+         dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM, mask_vectype);
+         dump_printf (MSG_MISSED_OPTIMIZATION,
+                      " does not match vector data type ");
+         dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM, vectype);
+         dump_printf (MSG_MISSED_OPTIMIZATION, ".\n");
+       }
+      return false;
+    }
+
+  *mask_vectype_out = mask_vectype;
+  return true;
+}
+
 /* Function vectorizable_mask_load_store.
 
    Check if STMT performs a conditional load or store that can be vectorized.
@@ -2066,11 +2134,6 @@ vectorizable_mask_load_store (gimple *stmt, gimple_stmt_iterator *gsi,
   ncopies = vect_get_num_copies (loop_vinfo, vectype);
   gcc_assert (ncopies >= 1);
 
-  mask = gimple_call_arg (stmt, 2);
-
-  if (!VECT_SCALAR_BOOLEAN_TYPE_P (TREE_TYPE (mask)))
-    return false;
-
   /* FORNOW. This restriction should be relaxed.  */
   if (nested_in_vect_loop && ncopies > 1)
     {
@@ -2090,21 +2153,11 @@ vectorizable_mask_load_store (gimple *stmt, gimple_stmt_iterator *gsi,
   if (!STMT_VINFO_DATA_REF (stmt_info))
     return false;
 
-  elem_type = TREE_TYPE (vectype);
-
-  if (TREE_CODE (mask) != SSA_NAME)
-    return false;
-
-  if (!vect_is_simple_use (mask, loop_vinfo, &def_stmt, &dt, &mask_vectype))
+  mask = gimple_call_arg (stmt, 2);
+  if (!vect_check_load_store_mask (stmt, mask, &mask_vectype))
     return false;
 
-  if (!mask_vectype)
-    mask_vectype = get_mask_type_for_scalar_type (TREE_TYPE (vectype));
-
-  if (!mask_vectype || !VECTOR_BOOLEAN_TYPE_P (mask_vectype)
-      || maybe_ne (TYPE_VECTOR_SUBPARTS (mask_vectype),
-                  TYPE_VECTOR_SUBPARTS (vectype)))
-    return false;
+  elem_type = TREE_TYPE (vectype);
 
   if (gimple_call_internal_fn (stmt) == IFN_MASK_STORE)
     {