Commit 8e846c66 by Richard Biener Committed by Richard Biener

tree-vect-data-refs.c (vect_find_stmt_data_reference): New function, combining…

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
parent 1623d9f3
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.
2018-05-25 Bin Cheng <bin.cheng@arm.com> 2018-05-25 Bin Cheng <bin.cheng@arm.com>
PR tree-optimization/85720 PR tree-optimization/85720
......
...@@ -1774,40 +1774,12 @@ vect_analyze_loop_costing (loop_vec_info loop_vinfo) ...@@ -1774,40 +1774,12 @@ vect_analyze_loop_costing (loop_vec_info loop_vinfo)
return 1; 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 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; *n_stmts = 0;
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;
}
for (unsigned i = 0; i < loop->num_nodes; i++) for (unsigned i = 0; i < loop->num_nodes; i++)
for (gimple_stmt_iterator gsi = gsi_start_bb (bbs[i]); for (gimple_stmt_iterator gsi = gsi_start_bb (bbs[i]);
!gsi_end_p (gsi); gsi_next (&gsi)) !gsi_end_p (gsi); gsi_next (&gsi))
...@@ -1815,9 +1787,8 @@ vect_analyze_loop_2 (loop_vec_info loop_vinfo, bool &fatal) ...@@ -1815,9 +1787,8 @@ vect_analyze_loop_2 (loop_vec_info loop_vinfo, bool &fatal)
gimple *stmt = gsi_stmt (gsi); gimple *stmt = gsi_stmt (gsi);
if (is_gimple_debug (stmt)) if (is_gimple_debug (stmt))
continue; continue;
++n_stmts; ++(*n_stmts);
if (!find_data_references_in_stmt (loop, stmt, if (!vect_find_stmt_data_reference (loop, stmt, datarefs))
&LOOP_VINFO_DATAREFS (loop_vinfo)))
{ {
if (is_gimple_call (stmt) && loop->safelen) if (is_gimple_call (stmt) && loop->safelen)
{ {
...@@ -1849,14 +1820,55 @@ vect_analyze_loop_2 (loop_vec_info loop_vinfo, bool &fatal) ...@@ -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 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 /* Analyze the data references and also adjust the minimal
vectorization factor according to the loads and stores. */ vectorization factor according to the loads and stores. */
......
...@@ -3011,7 +3011,7 @@ vect_slp_bb (basic_block bb) ...@@ -3011,7 +3011,7 @@ vect_slp_bb (basic_block bb)
if (gimple_location (stmt) != UNKNOWN_LOCATION) if (gimple_location (stmt) != UNKNOWN_LOCATION)
vect_location = gimple_location (stmt); vect_location = gimple_location (stmt);
if (!find_data_references_in_stmt (NULL, stmt, &datarefs)) if (!vect_find_stmt_data_reference (NULL, stmt, &datarefs))
break; break;
} }
......
...@@ -1495,6 +1495,8 @@ extern bool vect_gather_scatter_fn_p (bool, bool, tree, tree, unsigned int, ...@@ -1495,6 +1495,8 @@ extern bool vect_gather_scatter_fn_p (bool, bool, tree, tree, unsigned int,
signop, int, internal_fn *, tree *); signop, int, internal_fn *, tree *);
extern bool vect_check_gather_scatter (gimple *, loop_vec_info, extern bool vect_check_gather_scatter (gimple *, loop_vec_info,
gather_scatter_info *); gather_scatter_info *);
extern bool vect_find_stmt_data_reference (loop_p, gimple *,
vec<data_reference_p> *);
extern bool vect_analyze_data_refs (vec_info *, poly_uint64 *); extern bool vect_analyze_data_refs (vec_info *, poly_uint64 *);
extern void vect_record_base_alignments (vec_info *); extern void vect_record_base_alignments (vec_info *);
extern tree vect_create_data_ref_ptr (gimple *, tree, struct loop *, tree, extern tree vect_create_data_ref_ptr (gimple *, tree, struct loop *, tree,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment