diff options
author | Richard Biener <rguenther@suse.de> | 2018-06-25 11:04:01 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2018-06-25 11:04:01 +0000 |
commit | ca823c85882f5a0ca9779d8cd7adfcec02549d3b (patch) | |
tree | 5ba2be9dfcf5d0e1a7deb28abaeace299556a695 /gcc/tree-vect-loop.c | |
parent | f2227a6696f136a181a208d291eb44769a7721e0 (diff) | |
download | gcc-ca823c85882f5a0ca9779d8cd7adfcec02549d3b.zip gcc-ca823c85882f5a0ca9779d8cd7adfcec02549d3b.tar.gz gcc-ca823c85882f5a0ca9779d8cd7adfcec02549d3b.tar.bz2 |
tree-vectorizer.h (struct vec_info_shared): New structure with parts split out from struct vec_info and loop_nest from...
2018-06-25 Richard Biener <rguenther@suse.de>
* tree-vectorizer.h (struct vec_info_shared): New structure
with parts split out from struct vec_info and loop_nest from
struct _loop_vec_info.
(struct vec_info): Adjust accordingly.
(struct _loop_vec_info): Likewise.
(LOOP_VINFO_LOOP_NEST): Adjust.
(LOOP_VINFO_DATAREFS): Likewise.
(LOOP_VINFO_DDRS): Likewise.
(struct _bb_vec_info): Likewise.
(BB_VINFO_DATAREFS): Likewise.
(BB_VINFO_DDRS): Likewise.
(struct _stmt_vec_info): Add dr_aux member.
(DR_VECT_AUX): Adjust to refer to member of DR_STMTs vinfo.
(DR_MISALIGNMENT_UNINITIALIZED): New.
(set_dr_misalignment): Adjust.
(dr_misalignment): Assert misalign isn't DR_MISALIGNMENT_UNINITIALIZED.
(vect_analyze_loop): Adjust prototype.
(vect_analyze_loop_form): Likewise.
* tree-vect-data-refs.c (vect_analyze_data_ref_dependences):
Compute dependences lazily.
(vect_record_base_alignments): Use shared datarefs/ddrs.
(vect_verify_datarefs_alignment): Likewise.
(vect_analyze_data_refs_alignment): Likewise.
(vect_analyze_data_ref_accesses): Likewise.
(vect_analyze_data_refs): Likewise.
* tree-vect-loop.c (_loop_vec_info::_loop_vec_info): Add
constructor parameter for shared part.
(vect_analyze_loop_form): Pass in shared part and adjust.
(vect_analyze_loop_2): Pass in storage for the number of
stmts. Move loop nest finding to the caller. Compute
datarefs lazily.
(vect_analyze_loop): Pass in shared part.
(vect_transform_loop): Verify shared datarefs are unchanged.
* tree-vect-slp.c (_bb_vec_info::_bb_vec_info): Add
constructor parameter for shared part.
(vect_slp_analyze_bb_1): Pass in shared part and adjust.
(vect_slp_bb): Verify shared datarefs are unchanged before
transform.
* tree-vect-stmts.c (ensure_base_align): Adjust for DR_AUX
change.
(new_stmt_vec_info): Initialize DR_AUX misalignment to
DR_MISALIGNMENT_UNINITIALIZED.
* tree-vectorizer.c (vec_info::vec_info): Add constructor
parameter for shared part.
(vec_info::~vec_info): Adjust.
(vec_info_shared::vec_info_shared): New.
(vec_info_shared::~vec_info_shared): Likewise.
(vec_info_shared::save_datarefs): Likewise.
(vec_info_shared::check_datarefs): Likewise.
(try_vectorize_loop_1): Construct shared part live for analyses
of a single loop for multiple vector sizes.
* tree-parloops.c (gather_scalar_reductions): Adjust.
From-SVN: r262009
Diffstat (limited to 'gcc/tree-vect-loop.c')
-rw-r--r-- | gcc/tree-vect-loop.c | 66 |
1 files changed, 38 insertions, 28 deletions
diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c index 5a73a97..dacc881 100644 --- a/gcc/tree-vect-loop.c +++ b/gcc/tree-vect-loop.c @@ -803,8 +803,8 @@ bb_in_loop_p (const_basic_block bb, const void *data) /* Create and initialize a new loop_vec_info struct for LOOP_IN, as well as stmt_vec_info structs for all the stmts in LOOP_IN. */ -_loop_vec_info::_loop_vec_info (struct loop *loop_in) - : vec_info (vec_info::loop, init_cost (loop_in)), +_loop_vec_info::_loop_vec_info (struct loop *loop_in, vec_info_shared *shared) + : vec_info (vec_info::loop, init_cost (loop_in), shared), loop (loop_in), bbs (XCNEWVEC (basic_block, loop->num_nodes)), num_itersm1 (NULL_TREE), @@ -1351,7 +1351,7 @@ vect_analyze_loop_form_1 (struct loop *loop, gcond **loop_cond, /* Analyze LOOP form and return a loop_vec_info if it is of suitable form. */ loop_vec_info -vect_analyze_loop_form (struct loop *loop) +vect_analyze_loop_form (struct loop *loop, vec_info_shared *shared) { tree assumptions, number_of_iterations, number_of_iterationsm1; gcond *loop_cond, *inner_loop_cond = NULL; @@ -1361,7 +1361,7 @@ vect_analyze_loop_form (struct loop *loop) &number_of_iterations, &inner_loop_cond)) return NULL; - loop_vec_info loop_vinfo = new _loop_vec_info (loop); + loop_vec_info loop_vinfo = new _loop_vec_info (loop, shared); LOOP_VINFO_NITERSM1 (loop_vinfo) = number_of_iterationsm1; LOOP_VINFO_NITERS (loop_vinfo) = number_of_iterations; LOOP_VINFO_NITERS_UNCHANGED (loop_vinfo) = number_of_iterations; @@ -1822,7 +1822,7 @@ vect_get_datarefs_in_loop (loop_p loop, basic_block *bbs, for it. The different analyses will record information in the loop_vec_info struct. */ static bool -vect_analyze_loop_2 (loop_vec_info loop_vinfo, bool &fatal) +vect_analyze_loop_2 (loop_vec_info loop_vinfo, bool &fatal, unsigned *n_stmts) { bool ok; int res; @@ -1836,29 +1836,25 @@ vect_analyze_loop_2 (loop_vec_info loop_vinfo, bool &fatal) and analyze their evolution in the loop. */ loop_p loop = LOOP_VINFO_LOOP (loop_vinfo); - if (!find_loop_nest (loop, &LOOP_VINFO_LOOP_NEST (loop_vinfo))) - { - if (dump_enabled_p ()) - dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, - "not vectorized: loop nest containing two " - "or more consecutive inner loops cannot be " - "vectorized\n"); - return false; - } /* Gather the data references and count stmts in the loop. */ - unsigned int n_stmts; - if (!vect_get_datarefs_in_loop (loop, LOOP_VINFO_BBS (loop_vinfo), - &LOOP_VINFO_DATAREFS (loop_vinfo), - &n_stmts)) + if (!LOOP_VINFO_DATAREFS (loop_vinfo).exists ()) { - if (dump_enabled_p ()) - dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, - "not vectorized: loop contains function " - "calls or data references that cannot " - "be analyzed\n"); - return false; + if (!vect_get_datarefs_in_loop (loop, LOOP_VINFO_BBS (loop_vinfo), + &LOOP_VINFO_DATAREFS (loop_vinfo), + n_stmts)) + { + if (dump_enabled_p ()) + dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, + "not vectorized: loop contains function " + "calls or data references that cannot " + "be analyzed\n"); + return false; + } + loop_vinfo->shared->save_datarefs (); } + else + loop_vinfo->shared->check_datarefs (); /* Analyze the data references and also adjust the minimal vectorization factor according to the loads and stores. */ @@ -1947,7 +1943,7 @@ vect_analyze_loop_2 (loop_vec_info loop_vinfo, bool &fatal) unsigned th; /* Check the SLP opportunities in the loop, analyze and build SLP trees. */ - ok = vect_analyze_slp (loop_vinfo, n_stmts); + ok = vect_analyze_slp (loop_vinfo, *n_stmts); if (!ok) return false; @@ -2286,7 +2282,8 @@ again: loop_vec_info struct. If ORIG_LOOP_VINFO is not NULL epilogue must be vectorized. */ loop_vec_info -vect_analyze_loop (struct loop *loop, loop_vec_info orig_loop_vinfo) +vect_analyze_loop (struct loop *loop, loop_vec_info orig_loop_vinfo, + vec_info_shared *shared) { loop_vec_info loop_vinfo; auto_vector_sizes vector_sizes; @@ -2308,11 +2305,22 @@ vect_analyze_loop (struct loop *loop, loop_vec_info orig_loop_vinfo) return NULL; } + if (!find_loop_nest (loop, &shared->loop_nest)) + { + if (dump_enabled_p ()) + dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, + "not vectorized: loop nest containing two " + "or more consecutive inner loops cannot be " + "vectorized\n"); + return NULL; + } + + unsigned n_stmts; poly_uint64 autodetected_vector_size = 0; while (1) { /* Check the CFG characteristics of the loop (nesting, entry/exit). */ - loop_vinfo = vect_analyze_loop_form (loop); + loop_vinfo = vect_analyze_loop_form (loop, shared); if (!loop_vinfo) { if (dump_enabled_p ()) @@ -2326,7 +2334,7 @@ vect_analyze_loop (struct loop *loop, loop_vec_info orig_loop_vinfo) if (orig_loop_vinfo) LOOP_VINFO_ORIG_LOOP_INFO (loop_vinfo) = orig_loop_vinfo; - if (vect_analyze_loop_2 (loop_vinfo, fatal)) + if (vect_analyze_loop_2 (loop_vinfo, fatal, &n_stmts)) { LOOP_VINFO_VECTORIZABLE_P (loop_vinfo) = 1; @@ -8385,6 +8393,8 @@ vect_transform_loop (loop_vec_info loop_vinfo) DUMP_VECT_SCOPE ("vec_transform_loop"); + loop_vinfo->shared->check_datarefs (); + /* Use the more conservative vectorization threshold. If the number of iterations is constant assume the cost check has been performed by our caller. If the threshold makes all loops profitable that |