typedef struct data_ref_loc_d
{
- /* Position of the memory reference. */
- tree *pos;
+ /* Position of the memory reference. */
+ tree *pos;
- /* True if the memory reference is read. */
- bool is_read;
+ /* True if the memory reference is read. */
+ bool is_read;
} data_ref_loc;
true if STMT clobbers memory, false otherwise. */
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;
data_ref_loc ref;
tree *op0, *op1;
enum gimple_code stmt_code = gimple_code (stmt);
- references->create (0);
-
/* ASM_EXPR and CALL_EXPR may embed arbitrary side effects.
As we cannot model data-references to not spelled out
accesses give up if they may occur. */
vec<data_reference_p> *datarefs)
{
unsigned i;
- vec<data_ref_loc> references;
+ vec<data_ref_loc, va_stack> references;
data_ref_loc *ref;
bool ret = true;
data_reference_p dr;
+ vec_stack_alloc (data_ref_loc, references, 2);
if (get_references_in_stmt (stmt, &references))
{
references.release ();
vec<data_reference_p> *datarefs)
{
unsigned i;
- vec<data_ref_loc> references;
+ vec<data_ref_loc, va_stack> references;
data_ref_loc *ref;
bool ret = true;
data_reference_p dr;
+ vec_stack_alloc (data_ref_loc, references, 2);
if (get_references_in_stmt (stmt, &references))
{
references.release ();
TODO: This function should be made smarter so that it can handle address
arithmetic as if they were array accesses, etc. */
-static tree
+tree
find_data_references_in_loop (struct loop *loop,
vec<data_reference_p> *datarefs)
{
FOR_EACH_VEC_ELT (stmts, i, stmt)
{
- vec<data_ref_loc> references;
+ vec<data_ref_loc, va_stack> references;
data_ref_loc *ref;
struct vertex *v = &(rdg->vertices[i]);
if (gimple_code (stmt) == GIMPLE_PHI)
continue;
+ vec_stack_alloc (data_ref_loc, references, 2);
get_references_in_stmt (stmt, &references);
FOR_EACH_VEC_ELT (references, j, ref)
{
dump_printf_loc (MSG_NOTE, vect_location,
"=== vect_analyze_dependences ===");
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
- 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)
if (vect_analyze_data_ref_dependence (ddr, loop_vinfo, max_vf))
vec<data_reference_p> datarefs;
struct data_reference *dr;
tree scalar_type;
- bool res, stop_bb_analysis = false;
if (dump_enabled_p ())
dump_printf_loc (MSG_NOTE, vect_location,
if (loop_vinfo)
{
loop = LOOP_VINFO_LOOP (loop_vinfo);
- res = compute_data_dependences_for_loop
- (loop, true,
- &LOOP_VINFO_LOOP_NEST (loop_vinfo),
- &LOOP_VINFO_DATAREFS (loop_vinfo),
- &LOOP_VINFO_DDRS (loop_vinfo));
-
- if (!res)
+ if (!find_loop_nest (loop, &LOOP_VINFO_LOOP_NEST (loop_vinfo))
+ || find_data_references_in_loop
+ (loop, &LOOP_VINFO_DATAREFS (loop_vinfo)))
{
if (dump_enabled_p ())
dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
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);
}
stmt = DR_STMT (dr);
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. */
if (!DR_BASE_ADDRESS (dr) || !DR_OFFSET (dr) || !DR_INIT (dr)
|| !DR_STEP (dr))
}
if (bb_vinfo)
- {
- STMT_VINFO_VECTORIZABLE (stmt_info) = false;
- stop_bb_analysis = true;
- continue;
- }
+ break;
return false;
}
"constant");
if (bb_vinfo)
- {
- STMT_VINFO_VECTORIZABLE (stmt_info) = false;
- stop_bb_analysis = true;
- continue;
- }
+ break;
if (gather)
free_data_ref (dr);
}
if (bb_vinfo)
- {
- STMT_VINFO_VECTORIZABLE (stmt_info) = false;
- stop_bb_analysis = true;
- continue;
- }
+ break;
return false;
}
}
if (bb_vinfo)
- {
- STMT_VINFO_VECTORIZABLE (stmt_info) = false;
- stop_bb_analysis = true;
- continue;
- }
+ break;
if (gather)
free_data_ref (dr);
}
if (bb_vinfo)
- {
- STMT_VINFO_VECTORIZABLE (stmt_info) = false;
- stop_bb_analysis = true;
- continue;
- }
+ break;
if (gather)
free_data_ref (dr);
}
if (bb_vinfo)
- {
- STMT_VINFO_VECTORIZABLE (stmt_info) = false;
- stop_bb_analysis = true;
- continue;
- }
+ break;
if (gather)
free_data_ref (dr);
}
if (bb_vinfo)
- {
- STMT_VINFO_VECTORIZABLE (stmt_info) = false;
- stop_bb_analysis = true;
- continue;
- }
+ break;
if (gather)
free_data_ref (dr);
}
if (bb_vinfo)
- {
- /* Mark the statement as not vectorizable. */
- STMT_VINFO_VECTORIZABLE (stmt_info) = false;
- stop_bb_analysis = true;
- continue;
- }
+ break;
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;
- vec<loop_p> nest = LOOP_VINFO_LOOP_NEST (loop_vinfo);
gather = 0 != vect_check_gather (stmt, loop_vinfo, NULL, &off, NULL);
if (gather
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;
-
- 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;
}
else if (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;
}