* [PATCH] Cleanup BB vectorization roots handling
@ 2023-08-15 13:27 Richard Biener
0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2023-08-15 13:27 UTC (permalink / raw)
To: gcc-patches
The following moves CONSTRUCTOR handling into the generic BB
vectorization roots handling, removing a special case and finally
renaming the function now consisting of more than just constructor
detection.
Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.
* tree-vect-slp.cc (vect_analyze_slp_instance): Remove
slp_inst_kind_ctor handling.
(vect_analyze_slp): Simplify.
(vect_build_slp_instance): Dump when we analyze a CTOR.
(vect_slp_check_for_constructors): Rename to ...
(vect_slp_check_for_roots): ... this. Register a
slp_root for CONSTRUCTORs instead of shoving them to
the set of grouped stores.
(vect_slp_analyze_bb_1): Adjust.
---
gcc/tree-vect-slp.cc | 56 ++++++++++++++++++--------------------------
1 file changed, 23 insertions(+), 33 deletions(-)
diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc
index 40514e4758d..0563684928e 100644
--- a/gcc/tree-vect-slp.cc
+++ b/gcc/tree-vect-slp.cc
@@ -3123,6 +3123,14 @@ vect_build_slp_instance (vec_info *vinfo,
/* ??? We need stmt_info for group splitting. */
stmt_vec_info stmt_info_)
{
+ if (kind == slp_inst_kind_ctor)
+ {
+ if (dump_enabled_p ())
+ dump_printf_loc (MSG_NOTE, vect_location,
+ "Analyzing vectorizable constructor: %G\n",
+ root_stmt_infos[0]->stmt);
+ }
+
if (dump_enabled_p ())
{
dump_printf_loc (MSG_NOTE, vect_location,
@@ -3429,22 +3437,6 @@ vect_analyze_slp_instance (vec_info *vinfo,
STMT_VINFO_REDUC_DEF (vect_orig_stmt (stmt_info))
= STMT_VINFO_REDUC_DEF (vect_orig_stmt (scalar_stmts.last ()));
}
- else if (kind == slp_inst_kind_ctor)
- {
- tree rhs = gimple_assign_rhs1 (stmt_info->stmt);
- tree val;
- scalar_stmts.create (CONSTRUCTOR_NELTS (rhs));
- FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (rhs), i, val)
- {
- stmt_vec_info def_info = vinfo->lookup_def (val);
- def_info = vect_stmt_to_vectorize (def_info);
- scalar_stmts.quick_push (def_info);
- }
- if (dump_enabled_p ())
- dump_printf_loc (MSG_NOTE, vect_location,
- "Analyzing vectorizable constructor: %G\n",
- stmt_info->stmt);
- }
else if (kind == slp_inst_kind_reduc_group)
{
/* Collect reduction statements. */
@@ -3469,19 +3461,12 @@ vect_analyze_slp_instance (vec_info *vinfo,
vec<stmt_vec_info> roots = vNULL;
vec<tree> remain = vNULL;
- if (kind == slp_inst_kind_ctor)
- {
- roots.create (1);
- roots.quick_push (stmt_info);
- }
/* Build the tree for the SLP instance. */
bool res = vect_build_slp_instance (vinfo, kind, scalar_stmts,
roots, remain,
max_tree_size, limit, bst_map,
kind == slp_inst_kind_store
? stmt_info : NULL);
- if (!res)
- roots.release ();
/* ??? If this is slp_inst_kind_store and the above succeeded here's
where we should do store group splitting. */
@@ -3509,9 +3494,7 @@ vect_analyze_slp (vec_info *vinfo, unsigned max_tree_size)
/* Find SLP sequences starting from groups of grouped stores. */
FOR_EACH_VEC_ELT (vinfo->grouped_stores, i, first_element)
vect_analyze_slp_instance (vinfo, bst_map, first_element,
- STMT_VINFO_GROUPED_ACCESS (first_element)
- ? slp_inst_kind_store : slp_inst_kind_ctor,
- max_tree_size, &limit);
+ slp_inst_kind_store, max_tree_size, &limit);
if (bb_vec_info bb_vinfo = dyn_cast <bb_vec_info> (vinfo))
{
@@ -7106,7 +7089,7 @@ vect_slp_is_lane_insert (gimple *use_stmt, tree vec, unsigned *this_lane)
array. */
static void
-vect_slp_check_for_constructors (bb_vec_info bb_vinfo)
+vect_slp_check_for_roots (bb_vec_info bb_vinfo)
{
for (unsigned i = 0; i < bb_vinfo->bbs.length (); ++i)
for (gimple_stmt_iterator gsi = gsi_start_bb (bb_vinfo->bbs[i]);
@@ -7132,14 +7115,21 @@ vect_slp_check_for_constructors (bb_vec_info bb_vinfo)
unsigned j;
tree val;
FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (rhs), j, val)
- if (TREE_CODE (val) != SSA_NAME
- || !bb_vinfo->lookup_def (val))
- break;
+ if (TREE_CODE (val) != SSA_NAME
+ || !bb_vinfo->lookup_def (val))
+ break;
if (j != CONSTRUCTOR_NELTS (rhs))
continue;
- stmt_vec_info stmt_info = bb_vinfo->lookup_stmt (assign);
- BB_VINFO_GROUPED_STORES (bb_vinfo).safe_push (stmt_info);
+ vec<stmt_vec_info> roots = vNULL;
+ roots.safe_push (bb_vinfo->lookup_stmt (assign));
+ vec<stmt_vec_info> stmts;
+ stmts.create (CONSTRUCTOR_NELTS (rhs));
+ FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (rhs), j, val)
+ stmts.quick_push
+ (vect_stmt_to_vectorize (bb_vinfo->lookup_def (val)));
+ bb_vinfo->roots.safe_push (slp_root (slp_inst_kind_ctor,
+ stmts, roots));
}
else if (code == BIT_INSERT_EXPR
&& VECTOR_TYPE_P (TREE_TYPE (rhs))
@@ -7405,7 +7395,7 @@ vect_slp_analyze_bb_1 (bb_vec_info bb_vinfo, int n_stmts, bool &fatal,
return false;
}
- vect_slp_check_for_constructors (bb_vinfo);
+ vect_slp_check_for_roots (bb_vinfo);
/* If there are no grouped stores and no constructors in the region
there is no need to continue with pattern recog as vect_analyze_slp
--
2.35.3
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-08-15 13:27 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-15 13:27 [PATCH] Cleanup BB vectorization roots handling Richard Biener
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).