Commit fcac74a1 by Richard Biener Committed by Richard Biener

tree-data-ref.h (find_data_references_in_loop): Declare.

2013-03-18  Richard Biener  <rguenther@suse.de>

	* tree-data-ref.h (find_data_references_in_loop): Declare.
	* tree-data-ref.c (get_references_in_stmt): Use a stack
	vector pre-allocated in the callers.
	(find_data_references_in_stmt): Adjust.
	(graphite_find_data_references_in_stmt): Likewise.
	(create_rdg_vertices): Likewise.
	(find_data_references_in_loop): Export.
	* tree-vect-data-refs.c (vect_analyze_data_ref_dependences):
	Compute dependences here...
	(vect_analyze_data_refs): ...not here.  When we encounter
	a non-vectorizable data reference in basic-block vectorization
	truncate the data reference vector.  Do not bother to
	fixup data-dependence information for gather loads.
	* tree-vect-slp.c (vect_slp_analyze_bb_1): Check the number
	of data references, as reported.

From-SVN: r196775
parent ad6fdc19
2013-03-18 Richard Biener <rguenther@suse.de> 2013-03-18 Richard Biener <rguenther@suse.de>
* tree-data-ref.h (find_data_references_in_loop): Declare.
* tree-data-ref.c (get_references_in_stmt): Use a stack
vector pre-allocated in the callers.
(find_data_references_in_stmt): Adjust.
(graphite_find_data_references_in_stmt): Likewise.
(create_rdg_vertices): Likewise.
(find_data_references_in_loop): Export.
* tree-vect-data-refs.c (vect_analyze_data_ref_dependences):
Compute dependences here...
(vect_analyze_data_refs): ...not here. When we encounter
a non-vectorizable data reference in basic-block vectorization
truncate the data reference vector. Do not bother to
fixup data-dependence information for gather loads.
* tree-vect-slp.c (vect_slp_analyze_bb_1): Check the number
of data references, as reported.
2013-03-18 Richard Biener <rguenther@suse.de>
PR tree-optimization/3713 PR tree-optimization/3713
* tree-ssa-sccvn.c (visit_copy): Simplify. Always propagate * tree-ssa-sccvn.c (visit_copy): Simplify. Always propagate
has_constants and expr. has_constants and expr.
......
...@@ -4257,11 +4257,11 @@ compute_all_dependences (vec<data_reference_p> datarefs, ...@@ -4257,11 +4257,11 @@ compute_all_dependences (vec<data_reference_p> datarefs,
typedef struct data_ref_loc_d typedef struct data_ref_loc_d
{ {
/* Position of the memory reference. */ /* Position of the memory reference. */
tree *pos; tree *pos;
/* True if the memory reference is read. */ /* True if the memory reference is read. */
bool is_read; bool is_read;
} data_ref_loc; } data_ref_loc;
...@@ -4269,15 +4269,13 @@ typedef struct data_ref_loc_d ...@@ -4269,15 +4269,13 @@ typedef struct data_ref_loc_d
true if STMT clobbers memory, false otherwise. */ true if STMT clobbers memory, false otherwise. */
static bool static bool
get_references_in_stmt (gimple stmt, vec<data_ref_loc> *references) get_references_in_stmt (gimple stmt, vec<data_ref_loc, va_stack> *references)
{ {
bool clobbers_memory = false; bool clobbers_memory = false;
data_ref_loc ref; data_ref_loc ref;
tree *op0, *op1; tree *op0, *op1;
enum gimple_code stmt_code = gimple_code (stmt); enum gimple_code stmt_code = gimple_code (stmt);
references->create (0);
/* ASM_EXPR and CALL_EXPR may embed arbitrary side effects. /* ASM_EXPR and CALL_EXPR may embed arbitrary side effects.
As we cannot model data-references to not spelled out As we cannot model data-references to not spelled out
accesses give up if they may occur. */ accesses give up if they may occur. */
...@@ -4348,11 +4346,12 @@ find_data_references_in_stmt (struct loop *nest, gimple stmt, ...@@ -4348,11 +4346,12 @@ find_data_references_in_stmt (struct loop *nest, gimple stmt,
vec<data_reference_p> *datarefs) vec<data_reference_p> *datarefs)
{ {
unsigned i; unsigned i;
vec<data_ref_loc> references; vec<data_ref_loc, va_stack> references;
data_ref_loc *ref; data_ref_loc *ref;
bool ret = true; bool ret = true;
data_reference_p dr; data_reference_p dr;
vec_stack_alloc (data_ref_loc, references, 2);
if (get_references_in_stmt (stmt, &references)) if (get_references_in_stmt (stmt, &references))
{ {
references.release (); references.release ();
...@@ -4381,11 +4380,12 @@ graphite_find_data_references_in_stmt (loop_p nest, loop_p loop, gimple stmt, ...@@ -4381,11 +4380,12 @@ graphite_find_data_references_in_stmt (loop_p nest, loop_p loop, gimple stmt,
vec<data_reference_p> *datarefs) vec<data_reference_p> *datarefs)
{ {
unsigned i; unsigned i;
vec<data_ref_loc> references; vec<data_ref_loc, va_stack> references;
data_ref_loc *ref; data_ref_loc *ref;
bool ret = true; bool ret = true;
data_reference_p dr; data_reference_p dr;
vec_stack_alloc (data_ref_loc, references, 2);
if (get_references_in_stmt (stmt, &references)) if (get_references_in_stmt (stmt, &references))
{ {
references.release (); references.release ();
...@@ -4437,7 +4437,7 @@ find_data_references_in_bb (struct loop *loop, basic_block bb, ...@@ -4437,7 +4437,7 @@ find_data_references_in_bb (struct loop *loop, basic_block bb,
TODO: This function should be made smarter so that it can handle address TODO: This function should be made smarter so that it can handle address
arithmetic as if they were array accesses, etc. */ arithmetic as if they were array accesses, etc. */
static tree tree
find_data_references_in_loop (struct loop *loop, find_data_references_in_loop (struct loop *loop,
vec<data_reference_p> *datarefs) vec<data_reference_p> *datarefs)
{ {
...@@ -5005,7 +5005,7 @@ create_rdg_vertices (struct graph *rdg, vec<gimple> stmts, loop_p loop) ...@@ -5005,7 +5005,7 @@ create_rdg_vertices (struct graph *rdg, vec<gimple> stmts, loop_p loop)
FOR_EACH_VEC_ELT (stmts, i, stmt) FOR_EACH_VEC_ELT (stmts, i, stmt)
{ {
vec<data_ref_loc> references; vec<data_ref_loc, va_stack> references;
data_ref_loc *ref; data_ref_loc *ref;
struct vertex *v = &(rdg->vertices[i]); struct vertex *v = &(rdg->vertices[i]);
...@@ -5020,6 +5020,7 @@ create_rdg_vertices (struct graph *rdg, vec<gimple> stmts, loop_p loop) ...@@ -5020,6 +5020,7 @@ create_rdg_vertices (struct graph *rdg, vec<gimple> stmts, loop_p loop)
if (gimple_code (stmt) == GIMPLE_PHI) if (gimple_code (stmt) == GIMPLE_PHI)
continue; continue;
vec_stack_alloc (data_ref_loc, references, 2);
get_references_in_stmt (stmt, &references); get_references_in_stmt (stmt, &references);
FOR_EACH_VEC_ELT (references, j, ref) FOR_EACH_VEC_ELT (references, j, ref)
{ {
......
...@@ -382,6 +382,7 @@ extern bool find_data_references_in_stmt (struct loop *, gimple, ...@@ -382,6 +382,7 @@ extern bool find_data_references_in_stmt (struct loop *, gimple,
vec<data_reference_p> *); vec<data_reference_p> *);
extern bool graphite_find_data_references_in_stmt (loop_p, loop_p, gimple, extern bool graphite_find_data_references_in_stmt (loop_p, loop_p, gimple,
vec<data_reference_p> *); vec<data_reference_p> *);
tree find_data_references_in_loop (struct loop *, vec<data_reference_p> *);
struct data_reference *create_data_ref (loop_p, loop_p, tree, gimple, bool); struct data_reference *create_data_ref (loop_p, loop_p, tree, gimple, bool);
extern bool find_loop_nest (struct loop *, vec<loop_p> *); extern bool find_loop_nest (struct loop *, vec<loop_p> *);
extern struct data_dependence_relation *initialize_data_dependence_relation extern struct data_dependence_relation *initialize_data_dependence_relation
......
...@@ -798,9 +798,21 @@ vect_analyze_data_ref_dependences (loop_vec_info loop_vinfo, ...@@ -798,9 +798,21 @@ vect_analyze_data_ref_dependences (loop_vec_info loop_vinfo,
dump_printf_loc (MSG_NOTE, vect_location, dump_printf_loc (MSG_NOTE, vect_location,
"=== vect_analyze_dependences ==="); "=== vect_analyze_dependences ===");
if (loop_vinfo) if (loop_vinfo)
ddrs = LOOP_VINFO_DDRS (loop_vinfo); {
if (!compute_all_dependences (LOOP_VINFO_DATAREFS (loop_vinfo),
&LOOP_VINFO_DDRS (loop_vinfo),
LOOP_VINFO_LOOP_NEST (loop_vinfo), true))
return false;
ddrs = LOOP_VINFO_DDRS (loop_vinfo);
}
else else
ddrs = BB_VINFO_DDRS (bb_vinfo); {
if (!compute_all_dependences (BB_VINFO_DATAREFS (bb_vinfo),
&BB_VINFO_DDRS (bb_vinfo),
vNULL, true))
return false;
ddrs = BB_VINFO_DDRS (bb_vinfo);
}
FOR_EACH_VEC_ELT (ddrs, i, ddr) FOR_EACH_VEC_ELT (ddrs, i, ddr)
if (vect_analyze_data_ref_dependence (ddr, loop_vinfo, max_vf)) if (vect_analyze_data_ref_dependence (ddr, loop_vinfo, max_vf))
...@@ -2941,7 +2953,6 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo, ...@@ -2941,7 +2953,6 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,
vec<data_reference_p> datarefs; vec<data_reference_p> datarefs;
struct data_reference *dr; struct data_reference *dr;
tree scalar_type; tree scalar_type;
bool res, stop_bb_analysis = false;
if (dump_enabled_p ()) if (dump_enabled_p ())
dump_printf_loc (MSG_NOTE, vect_location, dump_printf_loc (MSG_NOTE, vect_location,
...@@ -2950,13 +2961,9 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo, ...@@ -2950,13 +2961,9 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,
if (loop_vinfo) if (loop_vinfo)
{ {
loop = LOOP_VINFO_LOOP (loop_vinfo); loop = LOOP_VINFO_LOOP (loop_vinfo);
res = compute_data_dependences_for_loop if (!find_loop_nest (loop, &LOOP_VINFO_LOOP_NEST (loop_vinfo))
(loop, true, || find_data_references_in_loop
&LOOP_VINFO_LOOP_NEST (loop_vinfo), (loop, &LOOP_VINFO_DATAREFS (loop_vinfo)))
&LOOP_VINFO_DATAREFS (loop_vinfo),
&LOOP_VINFO_DDRS (loop_vinfo));
if (!res)
{ {
if (dump_enabled_p ()) if (dump_enabled_p ())
dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
...@@ -2987,17 +2994,6 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo, ...@@ -2987,17 +2994,6 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,
break; break;
} }
} }
if (!compute_all_dependences (BB_VINFO_DATAREFS (bb_vinfo),
&BB_VINFO_DDRS (bb_vinfo),
vNULL, true))
{
if (dump_enabled_p ())
dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
"not vectorized: basic block contains function"
" calls or data references that cannot be"
" analyzed");
return false;
}
datarefs = BB_VINFO_DATAREFS (bb_vinfo); datarefs = BB_VINFO_DATAREFS (bb_vinfo);
} }
...@@ -3024,12 +3020,6 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo, ...@@ -3024,12 +3020,6 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,
stmt = DR_STMT (dr); stmt = DR_STMT (dr);
stmt_info = vinfo_for_stmt (stmt); stmt_info = vinfo_for_stmt (stmt);
if (stop_bb_analysis)
{
STMT_VINFO_VECTORIZABLE (stmt_info) = false;
continue;
}
/* Check that analysis of the data-ref succeeded. */ /* Check that analysis of the data-ref succeeded. */
if (!DR_BASE_ADDRESS (dr) || !DR_OFFSET (dr) || !DR_INIT (dr) if (!DR_BASE_ADDRESS (dr) || !DR_OFFSET (dr) || !DR_INIT (dr)
|| !DR_STEP (dr)) || !DR_STEP (dr))
...@@ -3070,11 +3060,7 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo, ...@@ -3070,11 +3060,7 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,
} }
if (bb_vinfo) if (bb_vinfo)
{ break;
STMT_VINFO_VECTORIZABLE (stmt_info) = false;
stop_bb_analysis = true;
continue;
}
return false; return false;
} }
...@@ -3088,11 +3074,7 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo, ...@@ -3088,11 +3074,7 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,
"constant"); "constant");
if (bb_vinfo) if (bb_vinfo)
{ break;
STMT_VINFO_VECTORIZABLE (stmt_info) = false;
stop_bb_analysis = true;
continue;
}
if (gather) if (gather)
free_data_ref (dr); free_data_ref (dr);
...@@ -3109,11 +3091,7 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo, ...@@ -3109,11 +3091,7 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,
} }
if (bb_vinfo) if (bb_vinfo)
{ break;
STMT_VINFO_VECTORIZABLE (stmt_info) = false;
stop_bb_analysis = true;
continue;
}
return false; return false;
} }
...@@ -3129,11 +3107,7 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo, ...@@ -3129,11 +3107,7 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,
} }
if (bb_vinfo) if (bb_vinfo)
{ break;
STMT_VINFO_VECTORIZABLE (stmt_info) = false;
stop_bb_analysis = true;
continue;
}
if (gather) if (gather)
free_data_ref (dr); free_data_ref (dr);
...@@ -3152,11 +3126,7 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo, ...@@ -3152,11 +3126,7 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,
} }
if (bb_vinfo) if (bb_vinfo)
{ break;
STMT_VINFO_VECTORIZABLE (stmt_info) = false;
stop_bb_analysis = true;
continue;
}
if (gather) if (gather)
free_data_ref (dr); free_data_ref (dr);
...@@ -3177,11 +3147,7 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo, ...@@ -3177,11 +3147,7 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,
} }
if (bb_vinfo) if (bb_vinfo)
{ break;
STMT_VINFO_VECTORIZABLE (stmt_info) = false;
stop_bb_analysis = true;
continue;
}
if (gather) if (gather)
free_data_ref (dr); free_data_ref (dr);
...@@ -3316,11 +3282,7 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo, ...@@ -3316,11 +3282,7 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,
} }
if (bb_vinfo) if (bb_vinfo)
{ break;
STMT_VINFO_VECTORIZABLE (stmt_info) = false;
stop_bb_analysis = true;
continue;
}
if (gather) if (gather)
free_data_ref (dr); free_data_ref (dr);
...@@ -3346,12 +3308,7 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo, ...@@ -3346,12 +3308,7 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,
} }
if (bb_vinfo) if (bb_vinfo)
{ break;
/* Mark the statement as not vectorizable. */
STMT_VINFO_VECTORIZABLE (stmt_info) = false;
stop_bb_analysis = true;
continue;
}
if (gather) if (gather)
{ {
...@@ -3369,14 +3326,7 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo, ...@@ -3369,14 +3326,7 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,
if (gather) if (gather)
{ {
unsigned int j, k, n;
struct data_reference *olddr
= datarefs[i];
vec<ddr_p> ddrs = LOOP_VINFO_DDRS (loop_vinfo);
struct data_dependence_relation *ddr, *newddr;
bool bad = false;
tree off; tree off;
vec<loop_p> nest = LOOP_VINFO_LOOP_NEST (loop_vinfo);
gather = 0 != vect_check_gather (stmt, loop_vinfo, NULL, &off, NULL); gather = 0 != vect_check_gather (stmt, loop_vinfo, NULL, &off, NULL);
if (gather if (gather
...@@ -3396,59 +3346,7 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo, ...@@ -3396,59 +3346,7 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,
return false; return false;
} }
n = datarefs.length () - 1;
for (j = 0, k = i - 1; j < i; j++)
{
ddr = ddrs[k];
gcc_assert (DDR_B (ddr) == olddr);
newddr = initialize_data_dependence_relation (DDR_A (ddr), dr,
nest);
ddrs[k] = newddr;
free_dependence_relation (ddr);
if (!bad
&& DR_IS_WRITE (DDR_A (newddr))
&& DDR_ARE_DEPENDENT (newddr) != chrec_known)
bad = true;
k += --n;
}
k++;
n = k + datarefs.length () - i - 1;
for (; k < n; k++)
{
ddr = ddrs[k];
gcc_assert (DDR_A (ddr) == olddr);
newddr = initialize_data_dependence_relation (dr, DDR_B (ddr),
nest);
ddrs[k] = newddr;
free_dependence_relation (ddr);
if (!bad
&& DR_IS_WRITE (DDR_B (newddr))
&& DDR_ARE_DEPENDENT (newddr) != chrec_known)
bad = true;
}
k = ddrs.length ()
- datarefs.length () + i;
ddr = ddrs[k];
gcc_assert (DDR_A (ddr) == olddr && DDR_B (ddr) == olddr);
newddr = initialize_data_dependence_relation (dr, dr, nest);
ddrs[k] = newddr;
free_dependence_relation (ddr);
datarefs[i] = dr; datarefs[i] = dr;
if (bad)
{
if (dump_enabled_p ())
{
dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
"not vectorized: data dependence conflict"
" prevents gather load");
dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, stmt, 0);
}
return false;
}
STMT_VINFO_GATHER_P (stmt_info) = true; STMT_VINFO_GATHER_P (stmt_info) = true;
} }
else if (loop_vinfo else if (loop_vinfo
...@@ -3472,6 +3370,22 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo, ...@@ -3472,6 +3370,22 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,
} }
} }
/* If we stopped analysis at the first dataref we could not analyze
when trying to vectorize a basic-block mark the rest of the datarefs
as not vectorizable and truncate the vector of datarefs. That
avoids spending useless time in analyzing their dependence. */
if (i != datarefs.length ())
{
gcc_assert (bb_vinfo != NULL);
for (unsigned j = i; j < datarefs.length (); ++j)
{
data_reference_p dr = datarefs[j];
STMT_VINFO_VECTORIZABLE (vinfo_for_stmt (DR_STMT (dr))) = false;
free_data_ref (dr);
}
datarefs.truncate (i);
}
return true; return true;
} }
......
...@@ -2078,7 +2078,6 @@ static bb_vec_info ...@@ -2078,7 +2078,6 @@ static bb_vec_info
vect_slp_analyze_bb_1 (basic_block bb) vect_slp_analyze_bb_1 (basic_block bb)
{ {
bb_vec_info bb_vinfo; bb_vec_info bb_vinfo;
vec<ddr_p> ddrs;
vec<slp_instance> slp_instances; vec<slp_instance> slp_instances;
slp_instance instance; slp_instance instance;
int i; int i;
...@@ -2100,8 +2099,7 @@ vect_slp_analyze_bb_1 (basic_block bb) ...@@ -2100,8 +2099,7 @@ vect_slp_analyze_bb_1 (basic_block bb)
return NULL; return NULL;
} }
ddrs = BB_VINFO_DDRS (bb_vinfo); if (BB_VINFO_DATAREFS (bb_vinfo).length () < 2)
if (!ddrs.length ())
{ {
if (dump_enabled_p ()) if (dump_enabled_p ())
dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
......
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