+2018-08-01 Richard Sandiford <richard.sandiford@arm.com>
+
+ * tree-vectorizer.h (vect_orig_stmt): New function.
+ * tree-vect-data-refs.c (vect_preserves_scalar_order_p): Use it.
+ * tree-vect-loop.c (vect_model_reduction_cost): Likewise.
+ (vect_create_epilog_for_reduction): Likewise.
+ (vectorizable_live_operation): Likewise.
+ * tree-vect-slp.c (vect_find_last_scalar_stmt_in_slp): Likewise.
+ (vect_detect_hybrid_slp_stmts, vect_schedule_slp): Likewise.
+ * tree-vect-stmts.c (vectorizable_call): Likewise.
+ (vectorizable_simd_clone_call, vect_remove_stores): Likewise.
+
2018-08-01 Richard Sandiford <richard.sandiford@arm.com>
* tree-vectorizer.h (vect_transform_stmt): Remove grouped_store
(but could happen later) while reads will happen no later than their
current position (but could happen earlier). Reordering is therefore
only possible if the first access is a write. */
- if (is_pattern_stmt_p (stmtinfo_a))
- stmtinfo_a = STMT_VINFO_RELATED_STMT (stmtinfo_a);
- if (is_pattern_stmt_p (stmtinfo_b))
- stmtinfo_b = STMT_VINFO_RELATED_STMT (stmtinfo_b);
+ stmtinfo_a = vect_orig_stmt (stmtinfo_a);
+ stmtinfo_b = vect_orig_stmt (stmtinfo_b);
stmt_vec_info earlier_stmt_info = get_earlier_stmt (stmtinfo_a, stmtinfo_b);
return !DR_IS_WRITE (STMT_VINFO_DATA_REF (earlier_stmt_info));
}
vectype = STMT_VINFO_VECTYPE (stmt_info);
mode = TYPE_MODE (vectype);
- stmt_vec_info orig_stmt_info = STMT_VINFO_RELATED_STMT (stmt_info);
-
- if (!orig_stmt_info)
- orig_stmt_info = stmt_info;
+ stmt_vec_info orig_stmt_info = vect_orig_stmt (stmt_info);
code = gimple_assign_rhs_code (orig_stmt_info->stmt);
Otherwise (it is a regular reduction) - the tree-code and scalar-def
are taken from STMT. */
- stmt_vec_info orig_stmt_info = STMT_VINFO_RELATED_STMT (stmt_info);
- if (!orig_stmt_info)
- {
- /* Regular reduction */
- orig_stmt_info = stmt_info;
- }
- else
+ stmt_vec_info orig_stmt_info = vect_orig_stmt (stmt_info);
+ if (orig_stmt_info != stmt_info)
{
/* Reduction pattern */
gcc_assert (STMT_VINFO_IN_PATTERN_P (orig_stmt_info));
if (REDUC_GROUP_FIRST_ELEMENT (stmt_info))
{
stmt_vec_info dest_stmt_info
- = SLP_TREE_SCALAR_STMTS (slp_node)[group_size - 1];
- /* Handle reduction patterns. */
- if (STMT_VINFO_RELATED_STMT (dest_stmt_info))
- dest_stmt_info = STMT_VINFO_RELATED_STMT (dest_stmt_info);
-
+ = vect_orig_stmt (SLP_TREE_SCALAR_STMTS (slp_node)[group_size - 1]);
scalar_dest = gimple_assign_lhs (dest_stmt_info->stmt);
group_size = 1;
}
return true;
}
- /* If stmt has a related stmt, then use that for getting the lhs. */
- gimple *stmt = (is_pattern_stmt_p (stmt_info)
- ? STMT_VINFO_RELATED_STMT (stmt_info)->stmt
- : stmt_info->stmt);
+ /* Use the lhs of the original scalar statement. */
+ gimple *stmt = vect_orig_stmt (stmt_info)->stmt;
lhs = (is_a <gphi *> (stmt)) ? gimple_phi_result (stmt)
: gimple_get_lhs (stmt);
for (int i = 0; SLP_TREE_SCALAR_STMTS (node).iterate (i, &stmt_vinfo); i++)
{
- if (is_pattern_stmt_p (stmt_vinfo))
- stmt_vinfo = STMT_VINFO_RELATED_STMT (stmt_vinfo);
+ stmt_vinfo = vect_orig_stmt (stmt_vinfo);
last = last ? get_later_stmt (stmt_vinfo, last) : stmt_vinfo;
}
gcc_checking_assert (PURE_SLP_STMT (stmt_vinfo));
/* If we get a pattern stmt here we have to use the LHS of the
original stmt for immediate uses. */
- gimple *stmt = stmt_vinfo->stmt;
- if (! STMT_VINFO_IN_PATTERN_P (stmt_vinfo)
- && STMT_VINFO_RELATED_STMT (stmt_vinfo))
- stmt = STMT_VINFO_RELATED_STMT (stmt_vinfo)->stmt;
+ gimple *stmt = vect_orig_stmt (stmt_vinfo)->stmt;
tree def;
if (gimple_code (stmt) == GIMPLE_PHI)
def = gimple_phi_result (stmt);
if (!STMT_VINFO_DATA_REF (store_info))
break;
- if (is_pattern_stmt_p (store_info))
- store_info = STMT_VINFO_RELATED_STMT (store_info);
+ store_info = vect_orig_stmt (store_info);
/* Free the attached stmt_vec_info and remove the stmt. */
vinfo->remove_stmt (store_info);
}
if (slp_node)
return true;
- if (is_pattern_stmt_p (stmt_info))
- stmt_info = STMT_VINFO_RELATED_STMT (stmt_info);
+ stmt_info = vect_orig_stmt (stmt_info);
lhs = gimple_get_lhs (stmt_info->stmt);
gassign *new_stmt
if (scalar_dest)
{
type = TREE_TYPE (scalar_dest);
- if (is_pattern_stmt_p (stmt_info))
- lhs = gimple_call_lhs (STMT_VINFO_RELATED_STMT (stmt_info)->stmt);
- else
- lhs = gimple_call_lhs (stmt);
+ lhs = gimple_call_lhs (vect_orig_stmt (stmt_info)->stmt);
new_stmt = gimple_build_assign (lhs, build_zero_cst (type));
}
else
while (next_stmt_info)
{
stmt_vec_info tmp = DR_GROUP_NEXT_ELEMENT (next_stmt_info);
- if (is_pattern_stmt_p (next_stmt_info))
- next_stmt_info = STMT_VINFO_RELATED_STMT (next_stmt_info);
+ next_stmt_info = vect_orig_stmt (next_stmt_info);
/* Free the attached stmt_vec_info and remove the stmt. */
vinfo->remove_stmt (next_stmt_info);
next_stmt_info = tmp;
return stmt_info->pattern_stmt_p;
}
+/* If STMT_INFO is a pattern statement, return the statement that it
+ replaces, otherwise return STMT_INFO itself. */
+
+inline stmt_vec_info
+vect_orig_stmt (stmt_vec_info stmt_info)
+{
+ if (is_pattern_stmt_p (stmt_info))
+ return STMT_VINFO_RELATED_STMT (stmt_info);
+ return stmt_info;
+}
+
/* Return true if BB is a loop header. */
static inline bool