2018-07-31 Richard Sandiford <richard.sandiford@arm.com>
+ * tree-vect-data-refs.c (vect_analyze_data_ref_dependence)
+ (vect_slp_analyze_node_dependences, vect_analyze_data_ref_accesses)
+ (vect_permute_store_chain, vect_permute_load_chain)
+ (vect_shift_permute_load_chain, vect_transform_grouped_load): Avoid
+ repeated stmt_vec_info lookups.
+ * tree-vect-loop-manip.c (vect_can_advance_ivs_p): Likewise.
+ (vect_update_ivs_after_vectorizer): Likewise.
+ * tree-vect-loop.c (vect_is_simple_reduction): Likewise.
+ (vect_create_epilog_for_reduction, vectorizable_reduction): Likewise.
+ * tree-vect-patterns.c (adjust_bool_stmts): Likewise.
+ * tree-vect-slp.c (vect_analyze_slp_instance): Likewise.
+ (vect_bb_slp_scalar_cost): Likewise.
+ * tree-vect-stmts.c (get_group_alias_ptr_type): Likewise.
+
+2018-07-31 Richard Sandiford <richard.sandiford@arm.com>
+
* tree-vect-data-refs.c (vect_check_gather_scatter): Pass the
gcall rather than the generic gimple stmt to gimple_call_internal_fn.
(vect_get_smallest_scalar_type, can_group_stmts_p): Use dyn_cast
... = a[i];
a[i+1] = ...;
where loads from the group interleave with the store. */
- if (!vect_preserves_scalar_order_p (vect_dr_stmt(dra),
- vect_dr_stmt (drb)))
+ if (!vect_preserves_scalar_order_p (stmtinfo_a, stmtinfo_b))
{
if (dump_enabled_p ())
dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
in NODE verifying we can sink them up to the last stmt in the
group. */
stmt_vec_info last_access_info = vect_find_last_scalar_stmt_in_slp (node);
+ vec_info *vinfo = last_access_info->vinfo;
for (unsigned k = 0; k < SLP_INSTANCE_GROUP_SIZE (instance); ++k)
{
stmt_vec_info access_info = SLP_TREE_SCALAR_STMTS (node)[k];
/* If we couldn't record a (single) data reference for this
stmt we have to resort to the alias oracle. */
- data_reference *dr_b = STMT_VINFO_DATA_REF (vinfo_for_stmt (stmt));
+ stmt_vec_info stmt_info = vinfo->lookup_stmt (stmt);
+ data_reference *dr_b = STMT_VINFO_DATA_REF (stmt_info);
if (!dr_b)
{
/* We are moving a store or sinking a load - this means
|| data_ref_compare_tree (DR_BASE_ADDRESS (dra),
DR_BASE_ADDRESS (drb)) != 0
|| data_ref_compare_tree (DR_OFFSET (dra), DR_OFFSET (drb)) != 0
- || !can_group_stmts_p (vect_dr_stmt (dra), vect_dr_stmt (drb)))
+ || !can_group_stmts_p (stmtinfo_a, stmtinfo_b))
break;
/* Check that the data-refs have the same constant size. */
/* Link the found element into the group list. */
if (!DR_GROUP_FIRST_ELEMENT (stmtinfo_a))
{
- DR_GROUP_FIRST_ELEMENT (stmtinfo_a) = vect_dr_stmt (dra);
+ DR_GROUP_FIRST_ELEMENT (stmtinfo_a) = stmtinfo_a;
lastinfo = stmtinfo_a;
}
- DR_GROUP_FIRST_ELEMENT (stmtinfo_b) = vect_dr_stmt (dra);
- DR_GROUP_NEXT_ELEMENT (lastinfo) = vect_dr_stmt (drb);
+ DR_GROUP_FIRST_ELEMENT (stmtinfo_b) = stmtinfo_a;
+ DR_GROUP_NEXT_ELEMENT (lastinfo) = stmtinfo_b;
lastinfo = stmtinfo_b;
}
}
gimple_stmt_iterator *gsi,
vec<tree> *result_chain)
{
+ stmt_vec_info stmt_info = vinfo_for_stmt (stmt);
tree vect1, vect2, high, low;
gimple *perm_stmt;
- tree vectype = STMT_VINFO_VECTYPE (vinfo_for_stmt (stmt));
+ tree vectype = STMT_VINFO_VECTYPE (stmt_info);
tree perm_mask_low, perm_mask_high;
tree data_ref;
tree perm3_mask_low, perm3_mask_high;
gimple_stmt_iterator *gsi,
vec<tree> *result_chain)
{
+ stmt_vec_info stmt_info = vinfo_for_stmt (stmt);
tree data_ref, first_vect, second_vect;
tree perm_mask_even, perm_mask_odd;
tree perm3_mask_low, perm3_mask_high;
gimple *perm_stmt;
- tree vectype = STMT_VINFO_VECTYPE (vinfo_for_stmt (stmt));
+ tree vectype = STMT_VINFO_VECTYPE (stmt_info);
unsigned int i, j, log_length = exact_log2 (length);
result_chain->quick_grow (length);
gimple_stmt_iterator *gsi,
vec<tree> *result_chain)
{
+ stmt_vec_info stmt_info = vinfo_for_stmt (stmt);
tree vect[3], vect_shift[3], data_ref, first_vect, second_vect;
tree perm2_mask1, perm2_mask2, perm3_mask;
tree select_mask, shift1_mask, shift2_mask, shift3_mask, shift4_mask;
gimple *perm_stmt;
- tree vectype = STMT_VINFO_VECTYPE (vinfo_for_stmt (stmt));
+ tree vectype = STMT_VINFO_VECTYPE (stmt_info);
unsigned int i;
- stmt_vec_info stmt_info = vinfo_for_stmt (stmt);
loop_vec_info loop_vinfo = STMT_VINFO_LOOP_VINFO (stmt_info);
unsigned HOST_WIDE_INT nelt, vf;
vect_transform_grouped_load (gimple *stmt, vec<tree> dr_chain, int size,
gimple_stmt_iterator *gsi)
{
+ stmt_vec_info stmt_info = vinfo_for_stmt (stmt);
machine_mode mode;
vec<tree> result_chain = vNULL;
/* If reassociation width for vector type is 2 or greater target machine can
execute 2 or more vector instructions in parallel. Otherwise try to
get chain for loads group using vect_shift_permute_load_chain. */
- mode = TYPE_MODE (STMT_VINFO_VECTYPE (vinfo_for_stmt (stmt)));
+ mode = TYPE_MODE (STMT_VINFO_VECTYPE (stmt_info));
if (targetm.sched.reassociation_width (VEC_PERM_EXPR, mode) > 1
|| pow2p_hwi (size)
|| !vect_shift_permute_load_chain (dr_chain, size, stmt,
tree evolution_part;
gphi *phi = gsi.phi ();
+ stmt_vec_info phi_info = loop_vinfo->lookup_stmt (phi);
if (dump_enabled_p ())
{
dump_printf_loc (MSG_NOTE, vect_location, "Analyze phi: ");
/* Analyze the evolution function. */
- evolution_part
- = STMT_VINFO_LOOP_PHI_EVOLUTION_PART (vinfo_for_stmt (phi));
+ evolution_part = STMT_VINFO_LOOP_PHI_EVOLUTION_PART (phi_info);
if (evolution_part == NULL_TREE)
{
if (dump_enabled_p ())
gphi *phi = gsi.phi ();
gphi *phi1 = gsi1.phi ();
+ stmt_vec_info phi_info = loop_vinfo->lookup_stmt (phi);
if (dump_enabled_p ())
{
dump_printf_loc (MSG_NOTE, vect_location,
}
type = TREE_TYPE (gimple_phi_result (phi));
- step_expr = STMT_VINFO_LOOP_PHI_EVOLUTION_PART (vinfo_for_stmt (phi));
+ step_expr = STMT_VINFO_LOOP_PHI_EVOLUTION_PART (phi_info);
step_expr = unshare_expr (step_expr);
/* FORNOW: We do not support IVs whose evolution function is a polynomial
}
/* Dissolve group eventually half-built by vect_is_slp_reduction. */
- stmt_vec_info first = REDUC_GROUP_FIRST_ELEMENT (vinfo_for_stmt (def_stmt));
+ stmt_vec_info first = REDUC_GROUP_FIRST_ELEMENT (def_stmt_info);
while (first)
{
stmt_vec_info next = REDUC_GROUP_NEXT_ELEMENT (first);
# b1 = phi <b2, b0>
a2 = operation (a1)
b2 = operation (b1) */
- slp_reduc = (slp_node && !REDUC_GROUP_FIRST_ELEMENT (vinfo_for_stmt (stmt)));
+ slp_reduc = (slp_node && !REDUC_GROUP_FIRST_ELEMENT (stmt_info));
/* True if we should implement SLP_REDUC using native reduction operations
instead of scalar operations. */
we may end up with more than one vector result. Here we reduce them to
one vector. */
- if (REDUC_GROUP_FIRST_ELEMENT (vinfo_for_stmt (stmt)) || direct_slp_reduc)
+ if (REDUC_GROUP_FIRST_ELEMENT (stmt_info) || direct_slp_reduc)
{
tree first_vect = PHI_RESULT (new_phis[0]);
gassign *new_vec_stmt = NULL;
necessary, hence we set here REDUC_GROUP_SIZE to 1. SCALAR_DEST is the
LHS of the last stmt in the reduction chain, since we are looking for
the loop exit phi node. */
- if (REDUC_GROUP_FIRST_ELEMENT (vinfo_for_stmt (stmt)))
+ if (REDUC_GROUP_FIRST_ELEMENT (stmt_info))
{
stmt_vec_info dest_stmt_info
= SLP_TREE_SCALAR_STMTS (slp_node)[group_size - 1];
tree cond_reduc_val = NULL_TREE;
/* Make sure it was already recognized as a reduction computation. */
- if (STMT_VINFO_DEF_TYPE (vinfo_for_stmt (stmt)) != vect_reduction_def
- && STMT_VINFO_DEF_TYPE (vinfo_for_stmt (stmt)) != vect_nested_cycle)
+ if (STMT_VINFO_DEF_TYPE (stmt_info) != vect_reduction_def
+ && STMT_VINFO_DEF_TYPE (stmt_info) != vect_nested_cycle)
return false;
if (nested_in_vect_loop_p (loop, stmt))
if (reduction_type == FOLD_LEFT_REDUCTION
&& slp_node
- && !REDUC_GROUP_FIRST_ELEMENT (vinfo_for_stmt (stmt)))
+ && !REDUC_GROUP_FIRST_ELEMENT (stmt_info))
{
/* We cannot use in-order reductions in this case because there is
an implicit reassociation of the operations involved. */
/* Check extra constraints for variable-length unchained SLP reductions. */
if (STMT_SLP_TYPE (stmt_info)
- && !REDUC_GROUP_FIRST_ELEMENT (vinfo_for_stmt (stmt))
+ && !REDUC_GROUP_FIRST_ELEMENT (stmt_info)
&& !nunits_out.is_constant ())
{
/* We checked above that we could build the initial vector when
adjust_bool_stmts (hash_set <gimple *> &bool_stmt_set,
tree out_type, gimple *stmt)
{
+ stmt_vec_info stmt_info = vinfo_for_stmt (stmt);
+
/* Gather original stmts in the bool pattern in their order of appearance
in the IL. */
auto_vec<gimple *> bool_stmts (bool_stmt_set.elements ());
hash_map <tree, tree> defs;
for (unsigned i = 0; i < bool_stmts.length (); ++i)
adjust_bool_pattern (gimple_assign_lhs (bool_stmts[i]),
- out_type, vinfo_for_stmt (stmt), defs);
+ out_type, stmt_info, defs);
/* Pop the last pattern seq stmt and install it as pattern root for STMT. */
gimple *pattern_stmt
- = gimple_seq_last_stmt (STMT_VINFO_PATTERN_DEF_SEQ (vinfo_for_stmt (stmt)));
+ = gimple_seq_last_stmt (STMT_VINFO_PATTERN_DEF_SEQ (stmt_info));
return gimple_assign_lhs (pattern_stmt);
}
vector size. */
unsigned HOST_WIDE_INT const_nunits;
if (is_a <bb_vec_info> (vinfo)
- && STMT_VINFO_GROUPED_ACCESS (vinfo_for_stmt (stmt))
- && DR_GROUP_FIRST_ELEMENT (vinfo_for_stmt (stmt))
+ && STMT_VINFO_GROUPED_ACCESS (stmt_info)
+ && DR_GROUP_FIRST_ELEMENT (stmt_info)
&& nunits.is_constant (&const_nunits))
{
/* We consider breaking the group only on VF boundaries from the existing
FOR_EACH_VEC_ELT (SLP_TREE_SCALAR_STMTS (node), i, stmt_info)
{
gimple *stmt = stmt_info->stmt;
+ vec_info *vinfo = stmt_info->vinfo;
ssa_op_iter op_iter;
def_operand_p def_p;
imm_use_iterator use_iter;
gimple *use_stmt;
FOR_EACH_IMM_USE_STMT (use_stmt, use_iter, DEF_FROM_PTR (def_p))
- if (!is_gimple_debug (use_stmt)
- && (! vect_stmt_in_region_p (stmt_info->vinfo, use_stmt)
- || ! PURE_SLP_STMT (vinfo_for_stmt (use_stmt))))
+ if (!is_gimple_debug (use_stmt))
{
- (*life)[i] = true;
- BREAK_FROM_IMM_USE_STMT (use_iter);
+ stmt_vec_info use_stmt_info = vinfo->lookup_stmt (use_stmt);
+ if (!use_stmt_info || !PURE_SLP_STMT (use_stmt_info))
+ {
+ (*life)[i] = true;
+ BREAK_FROM_IMM_USE_STMT (use_iter);
+ }
}
}
if ((*life)[i])
static tree
get_group_alias_ptr_type (gimple *first_stmt)
{
+ stmt_vec_info first_stmt_info = vinfo_for_stmt (first_stmt);
struct data_reference *first_dr, *next_dr;
- first_dr = STMT_VINFO_DATA_REF (vinfo_for_stmt (first_stmt));
- stmt_vec_info next_stmt_info
- = DR_GROUP_NEXT_ELEMENT (vinfo_for_stmt (first_stmt));
+ first_dr = STMT_VINFO_DATA_REF (first_stmt_info);
+ stmt_vec_info next_stmt_info = DR_GROUP_NEXT_ELEMENT (first_stmt_info);
while (next_stmt_info)
{
next_dr = STMT_VINFO_DATA_REF (next_stmt_info);