diff options
author | Richard Sandiford <richard.sandiford@linaro.org> | 2017-08-04 10:41:12 +0000 |
---|---|---|
committer | Richard Sandiford <rsandifo@gcc.gnu.org> | 2017-08-04 10:41:12 +0000 |
commit | 2c515559f9dbe8bace5f68e2fec7600a9edc7c42 (patch) | |
tree | 1be469fb15d4c42c3e6f4ef2d854914280c6b919 /gcc/tree-vectorizer.c | |
parent | 9adee3052156ae36271be28e3ad47dd975c26f42 (diff) | |
download | gcc-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.c')
-rw-r--r-- | gcc/tree-vectorizer.c | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/gcc/tree-vectorizer.c b/gcc/tree-vectorizer.c index 33a1f58..129129f 100644 --- a/gcc/tree-vectorizer.c +++ b/gcc/tree-vectorizer.c @@ -354,22 +354,36 @@ shrink_simd_arrays delete simd_array_to_simduid_htab; } -/* A helper function to free data refs. */ +/* Initialize the vec_info with kind KIND_IN and target cost data + TARGET_COST_DATA_IN. */ + +vec_info::vec_info (vec_info::vec_kind kind_in, void *target_cost_data_in) + : kind (kind_in), + datarefs (vNULL), + ddrs (vNULL), + target_cost_data (target_cost_data_in) +{ +} -void -vect_destroy_datarefs (vec_info *vinfo) +vec_info::~vec_info () { + slp_instance instance; struct data_reference *dr; unsigned int i; - FOR_EACH_VEC_ELT (vinfo->datarefs, i, dr) + FOR_EACH_VEC_ELT (datarefs, i, dr) if (dr->aux) { free (dr->aux); dr->aux = NULL; } - free_data_refs (vinfo->datarefs); + FOR_EACH_VEC_ELT (slp_instances, i, instance) + vect_free_slp_instance (instance); + + free_data_refs (datarefs); + free_dependence_relations (ddrs); + destroy_cost_data (target_cost_data); } /* A helper function to free scev and LOOP niter information, as well as @@ -830,7 +844,7 @@ vectorize_loops (void) has_mask_store = false; if (loop_vinfo) has_mask_store = LOOP_VINFO_HAS_MASK_STORE (loop_vinfo); - destroy_loop_vec_info (loop_vinfo, true); + delete loop_vinfo; if (has_mask_store) optimize_mask_stores (loop); loop->aux = NULL; |