diff options
author | Richard Biener <rguenther@suse.de> | 2018-05-25 11:11:12 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2018-05-25 11:11:12 +0000 |
commit | 8e846c6670b85cd69a5760a604d8f9ce0dbc3730 (patch) | |
tree | 4db30c2f8a4c9100b554917beeb46b515cf6af47 /gcc/tree-vect-loop.c | |
parent | 1623d9f346086582c49cb747c3dabd062e730c42 (diff) | |
download | gcc-8e846c6670b85cd69a5760a604d8f9ce0dbc3730.zip gcc-8e846c6670b85cd69a5760a604d8f9ce0dbc3730.tar.gz gcc-8e846c6670b85cd69a5760a604d8f9ce0dbc3730.tar.bz2 |
tree-vect-data-refs.c (vect_find_stmt_data_reference): New function, combining stmt data ref gathering and fatal analysis parts.
2018-05-25 Richard Biener <rguenther@suse.de>
* tree-vect-data-refs.c (vect_find_stmt_data_reference): New
function, combining stmt data ref gathering and fatal analysis
parts.
(vect_analyze_data_refs): Remove now redudnant code and simplify.
* tree-vect-loop.c (vect_get_datarefs_in_loop): Factor out from
vect_analyze_loop_2 and use vect_find_stmt_data_reference.
* tree-vect-slp.c (vect_slp_bb): Use vect_find_stmt_data_reference.
* tree-vectorizer.h (vect_find_stmt_data_reference): Declare.
From-SVN: r260754
Diffstat (limited to 'gcc/tree-vect-loop.c')
-rw-r--r-- | gcc/tree-vect-loop.c | 92 |
1 files changed, 52 insertions, 40 deletions
diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c index af9177e..c49e1c5 100644 --- a/gcc/tree-vect-loop.c +++ b/gcc/tree-vect-loop.c @@ -1774,40 +1774,12 @@ vect_analyze_loop_costing (loop_vec_info loop_vinfo) return 1; } - -/* Function vect_analyze_loop_2. - - Apply a set of analyses on LOOP, and create a loop_vec_info struct - 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_get_datarefs_in_loop (loop_p loop, basic_block *bbs, + vec<data_reference_p> *datarefs, + unsigned int *n_stmts) { - bool ok; - int res; - unsigned int max_vf = MAX_VECTORIZATION_FACTOR; - poly_uint64 min_vf = 2; - unsigned int n_stmts = 0; - - /* The first group of checks is independent of the vector size. */ - fatal = true; - - /* Find all data references in the loop (which correspond to vdefs/vuses) - and analyze their evolution in the loop. */ - - basic_block *bbs = LOOP_VINFO_BBS (loop_vinfo); - - 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; - } - + *n_stmts = 0; for (unsigned i = 0; i < loop->num_nodes; i++) for (gimple_stmt_iterator gsi = gsi_start_bb (bbs[i]); !gsi_end_p (gsi); gsi_next (&gsi)) @@ -1815,9 +1787,8 @@ vect_analyze_loop_2 (loop_vec_info loop_vinfo, bool &fatal) gimple *stmt = gsi_stmt (gsi); if (is_gimple_debug (stmt)) continue; - ++n_stmts; - if (!find_data_references_in_stmt (loop, stmt, - &LOOP_VINFO_DATAREFS (loop_vinfo))) + ++(*n_stmts); + if (!vect_find_stmt_data_reference (loop, stmt, datarefs)) { if (is_gimple_call (stmt) && loop->safelen) { @@ -1849,14 +1820,55 @@ vect_analyze_loop_2 (loop_vec_info loop_vinfo, bool &fatal) } } } - 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; } } + return true; +} + +/* Function vect_analyze_loop_2. + + Apply a set of analyses on LOOP, and create a loop_vec_info struct + 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) +{ + bool ok; + int res; + unsigned int max_vf = MAX_VECTORIZATION_FACTOR; + poly_uint64 min_vf = 2; + + /* The first group of checks is independent of the vector size. */ + fatal = true; + + /* Find all data references in the loop (which correspond to vdefs/vuses) + 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 (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; + } /* Analyze the data references and also adjust the minimal vectorization factor according to the loads and stores. */ |