aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-vectorizer.h
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-vectorizer.h
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-vectorizer.h')
-rw-r--r--gcc/tree-vectorizer.h44
1 files changed, 27 insertions, 17 deletions
diff --git a/gcc/tree-vectorizer.h b/gcc/tree-vectorizer.h
index 01c416c..e8acf66 100644
--- a/gcc/tree-vectorizer.h
+++ b/gcc/tree-vectorizer.h
@@ -155,20 +155,27 @@ typedef std::pair<tree, tree> vec_object_pair;
/* Vectorizer state common between loop and basic-block vectorization. */
struct vec_info {
- enum { bb, loop } kind;
+ enum vec_kind { bb, loop };
+
+ vec_info (vec_kind, void *);
+ ~vec_info ();
+
+ /* The type of vectorization. */
+ vec_kind kind;
/* All SLP instances. */
- vec<slp_instance> slp_instances;
+ auto_vec<slp_instance> slp_instances;
- /* All data references. */
+ /* All data references. Freed by free_data_refs, so not an auto_vec. */
vec<data_reference_p> datarefs;
- /* All data dependences. */
+ /* All data dependences. Freed by free_dependence_relations, so not
+ an auto_vec. */
vec<ddr_p> ddrs;
/* All interleaving chains of stores, represented by the first
stmt in the chain. */
- vec<gimple *> grouped_stores;
+ auto_vec<gimple *> grouped_stores;
/* Cost data used by the target cost model. */
void *target_cost_data;
@@ -198,6 +205,8 @@ is_a_helper <_bb_vec_info *>::test (vec_info *i)
/* Info on vectorized loops. */
/*-----------------------------------------------------------------*/
typedef struct _loop_vec_info : public vec_info {
+ _loop_vec_info (struct loop *);
+ ~_loop_vec_info ();
/* The loop to which this info struct refers to. */
struct loop *loop;
@@ -239,32 +248,32 @@ typedef struct _loop_vec_info : public vec_info {
int ptr_mask;
/* The loop nest in which the data dependences are computed. */
- vec<loop_p> loop_nest;
+ auto_vec<loop_p> loop_nest;
/* Data Dependence Relations defining address ranges that are candidates
for a run-time aliasing check. */
- vec<ddr_p> may_alias_ddrs;
+ auto_vec<ddr_p> may_alias_ddrs;
/* Data Dependence Relations defining address ranges together with segment
lengths from which the run-time aliasing check is built. */
- vec<dr_with_seg_len_pair_t> comp_alias_ddrs;
+ auto_vec<dr_with_seg_len_pair_t> comp_alias_ddrs;
/* Check that the addresses of each pair of objects is unequal. */
- vec<vec_object_pair> check_unequal_addrs;
+ auto_vec<vec_object_pair> check_unequal_addrs;
/* Statements in the loop that have data references that are candidates for a
runtime (loop versioning) misalignment check. */
- vec<gimple *> may_misalign_stmts;
+ auto_vec<gimple *> may_misalign_stmts;
/* Reduction cycles detected in the loop. Used in loop-aware SLP. */
- vec<gimple *> reductions;
+ auto_vec<gimple *> reductions;
/* All reduction chains in the loop, represented by the first
stmt in the chain. */
- vec<gimple *> reduction_chains;
+ auto_vec<gimple *> reduction_chains;
/* Cost vector for a single scalar iteration. */
- vec<stmt_info_for_cost> scalar_cost_vec;
+ auto_vec<stmt_info_for_cost> scalar_cost_vec;
/* The unrolling factor needed to SLP the loop. In case of that pure SLP is
applied to the loop, i.e., no unrolling is needed, this is 1. */
@@ -399,6 +408,9 @@ nested_in_vect_loop_p (struct loop *loop, gimple *stmt)
typedef struct _bb_vec_info : public vec_info
{
+ _bb_vec_info (gimple_stmt_iterator, gimple_stmt_iterator);
+ ~_bb_vec_info ();
+
basic_block bb;
gimple_stmt_iterator region_begin;
gimple_stmt_iterator region_end;
@@ -802,8 +814,8 @@ void free_stmt_vec_info_vec (void);
static inline stmt_vec_info
vinfo_for_stmt (gimple *stmt)
{
- unsigned int uid = gimple_uid (stmt);
- if (uid == 0)
+ int uid = gimple_uid (stmt);
+ if (uid <= 0)
return NULL;
return stmt_vec_info_vec[uid - 1];
@@ -1177,7 +1189,6 @@ extern tree vect_create_addr_base_for_vector_ref (gimple *, gimple_seq *,
/* In tree-vect-loop.c. */
/* FORNOW: Used in tree-parloops.c. */
-extern void destroy_loop_vec_info (loop_vec_info, bool);
extern gimple *vect_force_simple_reduction (loop_vec_info, gimple *,
bool *, bool);
/* Drive for loop analysis stage. */
@@ -1226,7 +1237,6 @@ void vect_pattern_recog (vec_info *);
/* In tree-vectorizer.c. */
unsigned vectorize_loops (void);
-void vect_destroy_datarefs (vec_info *);
bool vect_stmt_in_region_p (vec_info *, gimple *);
void vect_free_loop_info_assumptions (struct loop *);