From 1c5d68a677b076262c5508e6d4fbdb765cba2d2f Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Fri, 29 Nov 2019 14:47:34 +0000 Subject: [PATCH] Make vect_get_mask_type_for_stmt take a group size 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 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 | 10 ++++++++++ gcc/tree-vect-slp.c | 3 ++- gcc/tree-vect-stmts.c | 19 +++++++++++-------- gcc/tree-vectorizer.h | 4 ++-- 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e557946f697..d5a4f620be7 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2019-11-29 Richard Sandiford + + * 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 * tree-vect-stmts.c (vectorizable_operation): Punt early diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c index 48aca3b48f6..e3fd0e903a4 100644 --- a/gcc/tree-vect-slp.c +++ b/gcc/tree-vect-slp.c @@ -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. */ diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c index 49dcde43b74..f1e2ff4117f 100644 --- a/gcc/tree-vect-stmts.c +++ b/gcc/tree-vect-stmts.c @@ -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, diff --git a/gcc/tree-vectorizer.h b/gcc/tree-vectorizer.h index 0eac5bdef88..ad73519afaa 100644 --- a/gcc/tree-vectorizer.h +++ b/gcc/tree-vectorizer.h @@ -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); -- 2.30.2