aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-vect-slp.c
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@linaro.org>2017-08-04 10:41:12 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2017-08-04 10:41:12 +0000
commit2c515559f9dbe8bace5f68e2fec7600a9edc7c42 (patch)
tree1be469fb15d4c42c3e6f4ef2d854914280c6b919 /gcc/tree-vect-slp.c
parent9adee3052156ae36271be28e3ad47dd975c26f42 (diff)
downloadgcc-2c515559f9dbe8bace5f68e2fec7600a9edc7c42.zip
gcc-2c515559f9dbe8bace5f68e2fec7600a9edc7c42.tar.gz
gcc-2c515559f9dbe8bace5f68e2fec7600a9edc7c42.tar.bz2
C++-ify vec_info structures
This patch uses new, delete, constructors and desctructors to manage vec_info. This includes making ~vec_info free all the data shared by bb_vec_info and loop_vec_info, whereas previously the code was duplicated in destroy_bb_vec_info and destroy_loop_vec_info. This in turn meant changing the order of: FOR_EACH_VEC_ELT (slp_instances, i, instance) vect_free_slp_instance (instance); and: gimple_set_uid (stmt, -1); in destroy_bb_vec_info/~_bb_vec_info, so that now vect_free_slp_instance could see a uid of -1 as well as 0. The patch updates vinfo_for_stmt so that it returns NULL for a uid of -1. 2017-08-04 Richard Sandiford <richard.sandiford@linaro.org> gcc/ * tree-vectorizer.h (vec_info): Add a constructor and destructor. Add an explicit name for the enum. Use auto_vec for slp_instances and grouped_stores. (_loop_vec_info): Add a constructor and destructor. Use auto_vec for all vectors. (_bb_vec_info): Add a constructor and destructor. (vinfo_for_stmt): Return NULL for uids of -1 as well. (destroy_loop_vec_info): Delete. (vect_destroy_datarefs): Likewise. * tree-vectorizer.c (vect_destroy_datarefs): Delete. (vec_info::vec_info): New function. (vec_info::~vec_info): Likewise. (vectorize_loops): Use delete instead of destroy_loop_vec_info. * tree-parloops.c (gather_scalar_reductions): Use delete instead of destroy_loop_vec_info. * tree-vect-loop.c (new_loop_vec_info): Replace with... (_loop_vec_info::_loop_vec_info): ...this. (destroy_loop_vec_info): Replace with... (_loop_vec_info::~_loop_vec_info): ...this. Unconditionally delete the stmt_vec_infos. Leave handling of vec_info information to its destructor. Remove explicit vector releases. (vect_analyze_loop_form): Use new instead of new_loop_vec_info. (vect_analyze_loop): Use delete instead of destroy_loop_vec_info. * tree-vect-slp.c (new_bb_vec_info): Replace with... (_bb_vec_info::_bb_vec_info): ...this. Don't reserve space in BB_VINFO_GROUPED_STORES or BB_VINFO_SLP_INSTANCES. (destroy_bb_vec_info): Replace with... (_bb_vec_info::~_bb_vec_info): ...this. Leave handling of vec_info information to its destructor. (vect_slp_analyze_bb_1): Use new and delete instead of new_bb_vec_info and destroy_bb_vec_info. (vect_slp_bb): Replace 2 calls to destroy_bb_vec_info with a single delete. From-SVN: r250869
Diffstat (limited to 'gcc/tree-vect-slp.c')
-rw-r--r--gcc/tree-vect-slp.c79
1 files changed, 25 insertions, 54 deletions
diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c
index 032a944..c713745 100644
--- a/gcc/tree-vect-slp.c
+++ b/gcc/tree-vect-slp.c
@@ -2378,62 +2378,37 @@ vect_detect_hybrid_slp (loop_vec_info loop_vinfo)
}
-/* Create and initialize a new bb_vec_info struct for BB, as well as
- stmt_vec_info structs for all the stmts in it. */
-
-static bb_vec_info
-new_bb_vec_info (gimple_stmt_iterator region_begin,
- gimple_stmt_iterator region_end)
+/* Initialize a bb_vec_info struct for the statements between
+ REGION_BEGIN_IN (inclusive) and REGION_END_IN (exclusive). */
+
+_bb_vec_info::_bb_vec_info (gimple_stmt_iterator region_begin_in,
+ gimple_stmt_iterator region_end_in)
+ : vec_info (vec_info::bb, init_cost (NULL)),
+ bb (gsi_bb (region_begin_in)),
+ region_begin (region_begin_in),
+ region_end (region_end_in)
{
- basic_block bb = gsi_bb (region_begin);
- bb_vec_info res = NULL;
gimple_stmt_iterator gsi;
- res = (bb_vec_info) xcalloc (1, sizeof (struct _bb_vec_info));
- res->kind = vec_info::bb;
- BB_VINFO_BB (res) = bb;
- res->region_begin = region_begin;
- res->region_end = region_end;
-
for (gsi = region_begin; gsi_stmt (gsi) != gsi_stmt (region_end);
gsi_next (&gsi))
{
gimple *stmt = gsi_stmt (gsi);
gimple_set_uid (stmt, 0);
- set_vinfo_for_stmt (stmt, new_stmt_vec_info (stmt, res));
+ set_vinfo_for_stmt (stmt, new_stmt_vec_info (stmt, this));
}
- BB_VINFO_GROUPED_STORES (res).create (10);
- BB_VINFO_SLP_INSTANCES (res).create (2);
- BB_VINFO_TARGET_COST_DATA (res) = init_cost (NULL);
-
- bb->aux = res;
- return res;
+ bb->aux = this;
}
/* Free BB_VINFO struct, as well as all the stmt_vec_info structs of all the
stmts in the basic block. */
-static void
-destroy_bb_vec_info (bb_vec_info bb_vinfo)
+_bb_vec_info::~_bb_vec_info ()
{
- slp_instance instance;
- unsigned i;
-
- if (!bb_vinfo)
- return;
-
- vect_destroy_datarefs (bb_vinfo);
- free_dependence_relations (BB_VINFO_DDRS (bb_vinfo));
- BB_VINFO_GROUPED_STORES (bb_vinfo).release ();
- FOR_EACH_VEC_ELT (BB_VINFO_SLP_INSTANCES (bb_vinfo), i, instance)
- vect_free_slp_instance (instance);
- BB_VINFO_SLP_INSTANCES (bb_vinfo).release ();
- destroy_cost_data (BB_VINFO_TARGET_COST_DATA (bb_vinfo));
-
- for (gimple_stmt_iterator si = bb_vinfo->region_begin;
- gsi_stmt (si) != gsi_stmt (bb_vinfo->region_end); gsi_next (&si))
+ for (gimple_stmt_iterator si = region_begin;
+ gsi_stmt (si) != gsi_stmt (region_end); gsi_next (&si))
{
gimple *stmt = gsi_stmt (si);
stmt_vec_info stmt_info = vinfo_for_stmt (stmt);
@@ -2446,8 +2421,7 @@ destroy_bb_vec_info (bb_vec_info bb_vinfo)
gimple_set_uid (stmt, -1);
}
- BB_VINFO_BB (bb_vinfo)->aux = NULL;
- free (bb_vinfo);
+ bb->aux = NULL;
}
@@ -2729,7 +2703,7 @@ vect_slp_analyze_bb_1 (gimple_stmt_iterator region_begin,
return NULL;
}
- bb_vinfo = new_bb_vec_info (region_begin, region_end);
+ bb_vinfo = new _bb_vec_info (region_begin, region_end);
if (!bb_vinfo)
return NULL;
@@ -2744,7 +2718,7 @@ vect_slp_analyze_bb_1 (gimple_stmt_iterator region_begin,
"not vectorized: unhandled data-ref in basic "
"block.\n");
- destroy_bb_vec_info (bb_vinfo);
+ delete bb_vinfo;
return NULL;
}
@@ -2755,7 +2729,7 @@ vect_slp_analyze_bb_1 (gimple_stmt_iterator region_begin,
"not vectorized: not enough data-refs in "
"basic block.\n");
- destroy_bb_vec_info (bb_vinfo);
+ delete bb_vinfo;
return NULL;
}
@@ -2766,7 +2740,7 @@ vect_slp_analyze_bb_1 (gimple_stmt_iterator region_begin,
"not vectorized: unhandled data access in "
"basic block.\n");
- destroy_bb_vec_info (bb_vinfo);
+ delete bb_vinfo;
return NULL;
}
@@ -2780,7 +2754,7 @@ vect_slp_analyze_bb_1 (gimple_stmt_iterator region_begin,
"not vectorized: no grouped stores in "
"basic block.\n");
- destroy_bb_vec_info (bb_vinfo);
+ delete bb_vinfo;
return NULL;
}
@@ -2802,7 +2776,7 @@ vect_slp_analyze_bb_1 (gimple_stmt_iterator region_begin,
"in basic block.\n");
}
- destroy_bb_vec_info (bb_vinfo);
+ delete bb_vinfo;
return NULL;
}
@@ -2832,7 +2806,7 @@ vect_slp_analyze_bb_1 (gimple_stmt_iterator region_begin,
}
if (! BB_VINFO_SLP_INSTANCES (bb_vinfo).length ())
{
- destroy_bb_vec_info (bb_vinfo);
+ delete bb_vinfo;
return NULL;
}
@@ -2843,7 +2817,7 @@ vect_slp_analyze_bb_1 (gimple_stmt_iterator region_begin,
dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
"not vectorized: bad operation in basic block.\n");
- destroy_bb_vec_info (bb_vinfo);
+ delete bb_vinfo;
return NULL;
}
@@ -2856,7 +2830,7 @@ vect_slp_analyze_bb_1 (gimple_stmt_iterator region_begin,
"not vectorized: vectorization is not "
"profitable.\n");
- destroy_bb_vec_info (bb_vinfo);
+ delete bb_vinfo;
return NULL;
}
@@ -2936,12 +2910,9 @@ vect_slp_bb (basic_block bb)
dump_printf_loc (MSG_NOTE, vect_location,
"basic block part vectorized\n");
- destroy_bb_vec_info (bb_vinfo);
-
vectorized = true;
}
- else
- destroy_bb_vec_info (bb_vinfo);
+ delete bb_vinfo;
any_vectorized |= vectorized;