Make vect_get_mask_type_for_stmt take a group size
authorRichard Sandiford <richard.sandiford@arm.com>
Fri, 29 Nov 2019 14:47:34 +0000 (14:47 +0000)
committerRichard Sandiford <rsandifo@gcc.gnu.org>
Fri, 29 Nov 2019 14:47:34 +0000 (14:47 +0000)
This patch makes vect_get_mask_type_for_stmt and
get_mask_type_for_scalar_type take a group size instead of
the SLP node, so that later patches can call it before an
SLP node has been built.

2019-11-29  Richard Sandiford  <richard.sandiford@arm.com>

gcc/
* tree-vectorizer.h (get_mask_type_for_scalar_type): Replace
the slp_tree parameter with a group size parameter.
(vect_get_mask_type_for_stmt): Likewise.
* tree-vect-stmts.c (get_mask_type_for_scalar_type): Likewise.
(vect_get_mask_type_for_stmt): Likewise.
* tree-vect-slp.c (vect_slp_analyze_node_operations_1): Update
call accordingly.

From-SVN: r278849

gcc/ChangeLog
gcc/tree-vect-slp.c
gcc/tree-vect-stmts.c
gcc/tree-vectorizer.h

index e557946..d5a4f62 100644 (file)
@@ -1,5 +1,15 @@
 2019-11-29  Richard Sandiford  <richard.sandiford@arm.com>
 
+       * tree-vectorizer.h (get_mask_type_for_scalar_type): Replace
+       the slp_tree parameter with a group size parameter.
+       (vect_get_mask_type_for_stmt): Likewise.
+       * tree-vect-stmts.c (get_mask_type_for_scalar_type): Likewise.
+       (vect_get_mask_type_for_stmt): Likewise.
+       * tree-vect-slp.c (vect_slp_analyze_node_operations_1): Update
+       call accordingly.
+
+2019-11-29  Richard Sandiford  <richard.sandiford@arm.com>
+
        * tree-vect-stmts.c (vectorizable_operation): Punt early
        on codes that are handled elsewhere.
 
index 48aca3b..e3fd0e9 100644 (file)
@@ -2757,7 +2757,8 @@ vect_slp_analyze_node_operations_1 (vec_info *vinfo, slp_tree node,
   bb_vec_info bb_vinfo = STMT_VINFO_BB_VINFO (stmt_info);
   if (bb_vinfo && STMT_VINFO_VECTYPE (stmt_info) == boolean_type_node)
     {
-      tree vectype = vect_get_mask_type_for_stmt (stmt_info, node);
+      unsigned int group_size = SLP_TREE_SCALAR_STMTS (node).length ();
+      tree vectype = vect_get_mask_type_for_stmt (stmt_info, group_size);
       if (!vectype)
        /* vect_get_mask_type_for_stmt has already explained the
           failure.  */
index 49dcde4..f1e2ff4 100644 (file)
@@ -11323,14 +11323,15 @@ get_vectype_for_scalar_type (vec_info *vinfo, tree scalar_type, slp_tree node)
 
    Returns the mask type corresponding to a result of comparison
    of vectors of specified SCALAR_TYPE as supported by target.
-   NODE, if nonnull, is the SLP tree node that will use the returned
-   vector type.  */
+   If GROUP_SIZE is nonzero and we're performing BB vectorization,
+   make sure that the number of elements in the vector is no bigger
+   than GROUP_SIZE.  */
 
 tree
 get_mask_type_for_scalar_type (vec_info *vinfo, tree scalar_type,
-                              slp_tree node)
+                              unsigned int group_size)
 {
-  tree vectype = get_vectype_for_scalar_type (vinfo, scalar_type, node);
+  tree vectype = get_vectype_for_scalar_type (vinfo, scalar_type, group_size);
 
   if (!vectype)
     return NULL;
@@ -12190,11 +12191,12 @@ vect_get_vector_types_for_stmt (stmt_vec_info stmt_info,
 
 /* Try to determine the correct vector type for STMT_INFO, which is a
    statement that produces a scalar boolean result.  Return the vector
-   type on success, otherwise return NULL_TREE.  NODE, if nonnull,
-   is the SLP tree node that will use the returned vector type.  */
+   type on success, otherwise return NULL_TREE.  If GROUP_SIZE is nonzero
+   and we're performing BB vectorization, make sure that the number of
+   elements in the vector is no bigger than GROUP_SIZE.  */
 
 opt_tree
-vect_get_mask_type_for_stmt (stmt_vec_info stmt_info, slp_tree node)
+vect_get_mask_type_for_stmt (stmt_vec_info stmt_info, unsigned int group_size)
 {
   vec_info *vinfo = stmt_info->vinfo;
   gimple *stmt = stmt_info->stmt;
@@ -12206,7 +12208,8 @@ vect_get_mask_type_for_stmt (stmt_vec_info stmt_info, slp_tree node)
       && !VECT_SCALAR_BOOLEAN_TYPE_P (TREE_TYPE (gimple_assign_rhs1 (stmt))))
     {
       scalar_type = TREE_TYPE (gimple_assign_rhs1 (stmt));
-      mask_type = get_mask_type_for_scalar_type (vinfo, scalar_type, node);
+      mask_type = get_mask_type_for_scalar_type (vinfo, scalar_type,
+                                                group_size);
 
       if (!mask_type)
        return opt_tree::failure_at (stmt,
index 0eac5bd..ad73519 100644 (file)
@@ -1640,7 +1640,7 @@ extern tree get_related_vectype_for_scalar_type (machine_mode, tree,
                                                 poly_uint64 = 0);
 extern tree get_vectype_for_scalar_type (vec_info *, tree, unsigned int = 0);
 extern tree get_vectype_for_scalar_type (vec_info *, tree, slp_tree);
-extern tree get_mask_type_for_scalar_type (vec_info *, tree, slp_tree = 0);
+extern tree get_mask_type_for_scalar_type (vec_info *, tree, unsigned int = 0);
 extern tree get_same_sized_vectype (tree, tree);
 extern bool vect_chooses_same_modes_p (vec_info *, machine_mode);
 extern bool vect_get_loop_mask_type (loop_vec_info);
@@ -1693,7 +1693,7 @@ extern gcall *vect_gen_while (tree, tree, tree);
 extern tree vect_gen_while_not (gimple_seq *, tree, tree, tree);
 extern opt_result vect_get_vector_types_for_stmt (stmt_vec_info, tree *,
                                                  tree *, unsigned int = 0);
-extern opt_tree vect_get_mask_type_for_stmt (stmt_vec_info, slp_tree = 0);
+extern opt_tree vect_get_mask_type_for_stmt (stmt_vec_info, unsigned int = 0);
 
 /* In tree-vect-data-refs.c.  */
 extern bool vect_can_force_dr_alignment_p (const_tree, poly_uint64);