unsigned int i;
struct loop *loop = LOOP_VINFO_LOOP (loop_vinfo);
int vectorization_factor = LOOP_VINFO_VECT_FACTOR (loop_vinfo);
- unsigned int loop_depth = 0;
- struct loop *loop_nest = loop;
struct data_reference *dra = DDR_A (ddr);
struct data_reference *drb = DDR_B (ddr);
stmt_vec_info stmtinfo_a = vinfo_for_stmt (DR_STMT (dra));
stmt_vec_info stmtinfo_b = vinfo_for_stmt (DR_STMT (drb));
+ lambda_vector dist_v;
+ unsigned int loop_depth;
if (DDR_ARE_DEPENDENT (ddr) == chrec_known)
return false;
return true;
}
- /* Find loop depth. */
- while (loop_nest && loop_nest->outer && loop_nest->outer->outer)
+ loop_depth = index_in_loop_nest (loop->num, DDR_LOOP_NEST (ddr));
+ for (i = 0; VEC_iterate (lambda_vector, DDR_DIST_VECTS (ddr), i, dist_v); i++)
{
- loop_nest = loop_nest->outer;
- loop_depth++;
- }
-
- for (i = 0; i < DDR_NUM_DIST_VECTS (ddr); i++)
- {
- int dist = DDR_DIST_VECT (ddr, i)[loop_depth];
+ int dist = dist_v[loop_depth];
if (vect_print_dump_info (REPORT_DR_DETAILS))
fprintf (vect_dump, "dependence distance = %d.", dist);
vect_analyze_data_ref_dependences (loop_vec_info loop_vinfo)
{
unsigned int i;
- varray_type ddrs = LOOP_VINFO_DDRS (loop_vinfo);
+ VEC (ddr_p, heap) *ddrs = LOOP_VINFO_DDRS (loop_vinfo);
+ struct data_dependence_relation *ddr;
if (vect_print_dump_info (REPORT_DETAILS))
fprintf (vect_dump, "=== vect_analyze_dependences ===");
- for (i = 0; i < VARRAY_ACTIVE_SIZE (ddrs); i++)
- {
- struct data_dependence_relation *ddr = VARRAY_GENERIC_PTR (ddrs, i);
-
- if (vect_analyze_data_ref_dependence (ddr, loop_vinfo))
- return false;
- }
+ for (i = 0; VEC_iterate (ddr_p, ddrs, i, ddr); i++)
+ if (vect_analyze_data_ref_dependence (ddr, loop_vinfo))
+ return false;
return true;
}
if (!base_aligned)
{
- if (!vect_can_force_dr_alignment_p (base, TYPE_ALIGN (vectype)))
+ /* Do not change the alignment of global variables if
+ flag_section_anchors is enabled. */
+ if (!vect_can_force_dr_alignment_p (base, TYPE_ALIGN (vectype))
+ || (TREE_STATIC (base) && flag_section_anchors))
{
if (vect_print_dump_info (REPORT_DETAILS))
{
static bool
vect_compute_data_refs_alignment (loop_vec_info loop_vinfo)
{
- varray_type datarefs = LOOP_VINFO_DATAREFS (loop_vinfo);
+ VEC (data_reference_p, heap) *datarefs = LOOP_VINFO_DATAREFS (loop_vinfo);
+ struct data_reference *dr;
unsigned int i;
- for (i = 0; i < VARRAY_ACTIVE_SIZE (datarefs); i++)
- {
- struct data_reference *dr = VARRAY_GENERIC_PTR (datarefs, i);
- if (!vect_compute_data_ref_alignment (dr))
- return false;
- }
+ for (i = 0; VEC_iterate (data_reference_p, datarefs, i, dr); i++)
+ if (!vect_compute_data_ref_alignment (dr))
+ return false;
return true;
}
static bool
vect_verify_datarefs_alignment (loop_vec_info loop_vinfo)
{
- varray_type datarefs = LOOP_VINFO_DATAREFS (loop_vinfo);
+ VEC (data_reference_p, heap) *datarefs = LOOP_VINFO_DATAREFS (loop_vinfo);
+ struct data_reference *dr;
enum dr_alignment_support supportable_dr_alignment;
unsigned int i;
- for (i = 0; i < VARRAY_ACTIVE_SIZE (datarefs); i++)
+ for (i = 0; VEC_iterate (data_reference_p, datarefs, i, dr); i++)
{
- struct data_reference *dr = VARRAY_GENERIC_PTR (datarefs, i);
supportable_dr_alignment = vect_supportable_dr_alignment (dr);
if (!supportable_dr_alignment)
{
static bool
vect_enhance_data_refs_alignment (loop_vec_info loop_vinfo)
{
- varray_type datarefs = LOOP_VINFO_DATAREFS (loop_vinfo);
+ VEC (data_reference_p, heap) *datarefs = LOOP_VINFO_DATAREFS (loop_vinfo);
enum dr_alignment_support supportable_dr_alignment;
struct data_reference *dr0 = NULL;
struct data_reference *dr;
TODO: Use a cost model. */
- for (i = 0; i < VARRAY_ACTIVE_SIZE (datarefs); i++)
- {
- dr = VARRAY_GENERIC_PTR (datarefs, i);
- if (!DR_IS_READ (dr) && !aligned_access_p (dr))
- {
- dr0 = dr;
- do_peeling = true;
- break;
- }
- }
+ for (i = 0; VEC_iterate (data_reference_p, datarefs, i, dr); i++)
+ if (!DR_IS_READ (dr) && !aligned_access_p (dr))
+ {
+ dr0 = dr;
+ do_peeling = true;
+ break;
+ }
/* Often peeling for alignment will require peeling for loop-bound, which in
turn requires that we know how to adjust the loop ivs after the loop. */
}
/* Ensure that all data refs can be vectorized after the peel. */
- for (i = 0; i < VARRAY_ACTIVE_SIZE (datarefs); i++)
+ for (i = 0; VEC_iterate (data_reference_p, datarefs, i, dr); i++)
{
int save_misalignment;
- dr = VARRAY_GENERIC_PTR (datarefs, i);
if (dr == dr0)
continue;
+
save_misalignment = DR_MISALIGNMENT (dr);
vect_update_misalignment_for_peel (dr, dr0, npeel);
supportable_dr_alignment = vect_supportable_dr_alignment (dr);
by the peeling factor times the element size of DR_i (MOD the
vectorization factor times the size). Otherwise, the
misalignment of DR_i must be set to unknown. */
- for (i = 0; i < VARRAY_ACTIVE_SIZE (datarefs); i++)
- {
- dr = VARRAY_GENERIC_PTR (datarefs, i);
- if (dr == dr0)
- continue;
+ for (i = 0; VEC_iterate (data_reference_p, datarefs, i, dr); i++)
+ if (dr != dr0)
vect_update_misalignment_for_peel (dr, dr0, npeel);
- }
LOOP_VINFO_UNALIGNED_DR (loop_vinfo) = dr0;
LOOP_PEELING_FOR_ALIGNMENT (loop_vinfo) = DR_MISALIGNMENT (dr0);
if (do_versioning)
{
- for (i = 0; i < VARRAY_ACTIVE_SIZE (datarefs); i++)
+ for (i = 0; VEC_iterate (data_reference_p, datarefs, i, dr); i++)
{
- dr = VARRAY_GENERIC_PTR (datarefs, i);
-
if (aligned_access_p (dr))
continue;
vect_analyze_data_ref_accesses (loop_vec_info loop_vinfo)
{
unsigned int i;
- varray_type datarefs = LOOP_VINFO_DATAREFS (loop_vinfo);
+ VEC (data_reference_p, heap) *datarefs = LOOP_VINFO_DATAREFS (loop_vinfo);
+ struct data_reference *dr;
if (vect_print_dump_info (REPORT_DETAILS))
fprintf (vect_dump, "=== vect_analyze_data_ref_accesses ===");
- for (i = 0; i < VARRAY_ACTIVE_SIZE (datarefs); i++)
- {
- struct data_reference *dr = VARRAY_GENERIC_PTR (datarefs, i);
- if (!vect_analyze_data_ref_access (dr))
- {
- if (vect_print_dump_info (REPORT_UNVECTORIZED_LOOPS))
- fprintf (vect_dump, "not vectorized: complicated access pattern.");
- return false;
- }
- }
+ for (i = 0; VEC_iterate (data_reference_p, datarefs, i, dr); i++)
+ if (!vect_analyze_data_ref_access (dr))
+ {
+ if (vect_print_dump_info (REPORT_UNVECTORIZED_LOOPS))
+ fprintf (vect_dump, "not vectorized: complicated access pattern.");
+ return false;
+ }
return true;
}
{
struct loop *loop = LOOP_VINFO_LOOP (loop_vinfo);
unsigned int i;
- varray_type datarefs;
+ VEC (data_reference_p, heap) *datarefs;
+ struct data_reference *dr;
tree scalar_type;
if (vect_print_dump_info (REPORT_DETAILS))
fprintf (vect_dump, "=== vect_analyze_data_refs ===");
compute_data_dependences_for_loop (loop, false,
- &(LOOP_VINFO_DATAREFS (loop_vinfo)),
- &(LOOP_VINFO_DDRS (loop_vinfo)));
+ &LOOP_VINFO_DATAREFS (loop_vinfo),
+ &LOOP_VINFO_DDRS (loop_vinfo));
/* Go through the data-refs, check that the analysis succeeded. Update pointer
from stmt_vec_info struct to DR and vectype. */
datarefs = LOOP_VINFO_DATAREFS (loop_vinfo);
- for (i = 0; i < VARRAY_ACTIVE_SIZE (datarefs); i++)
+
+ for (i = 0; VEC_iterate (data_reference_p, datarefs, i, dr); i++)
{
- struct data_reference *dr = VARRAY_GENERIC_PTR (datarefs, i);
tree stmt;
stmt_vec_info stmt_info;
that the loop is represented as a do-while (with a proper if-guard
before the loop if needed), where the loop header contains all the
executable statements, and the latch is empty. */
- if (!empty_block_p (loop->latch))
+ if (!empty_block_p (loop->latch)
+ || phi_nodes (loop->latch))
{
if (vect_print_dump_info (REPORT_BAD_FORM_LOOPS))
fprintf (vect_dump, "not vectorized: unexpected loop form.");