Commit 211cd1e2 by Richard Sandiford Committed by Richard Sandiford

[04/11] Add a vect_orig_stmt helper function

This patch just adds a helper function for going from a potential
pattern statement to the original scalar statement.

2018-08-01  Richard Sandiford  <richard.sandiford@arm.com>

gcc/
	* 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.

From-SVN: r263217
parent b0b45e58
2018-08-01 Richard Sandiford <richard.sandiford@arm.com> 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 * tree-vectorizer.h (vect_transform_stmt): Remove grouped_store
argument. argument.
* tree-vect-stmts.c (vect_transform_stmt): Likewise. * tree-vect-stmts.c (vect_transform_stmt): Likewise.
......
...@@ -214,10 +214,8 @@ vect_preserves_scalar_order_p (dr_vec_info *dr_info_a, dr_vec_info *dr_info_b) ...@@ -214,10 +214,8 @@ vect_preserves_scalar_order_p (dr_vec_info *dr_info_a, dr_vec_info *dr_info_b)
(but could happen later) while reads will happen no later than their (but could happen later) while reads will happen no later than their
current position (but could happen earlier). Reordering is therefore current position (but could happen earlier). Reordering is therefore
only possible if the first access is a write. */ only possible if the first access is a write. */
if (is_pattern_stmt_p (stmtinfo_a)) stmtinfo_a = vect_orig_stmt (stmtinfo_a);
stmtinfo_a = STMT_VINFO_RELATED_STMT (stmtinfo_a); stmtinfo_b = vect_orig_stmt (stmtinfo_b);
if (is_pattern_stmt_p (stmtinfo_b))
stmtinfo_b = STMT_VINFO_RELATED_STMT (stmtinfo_b);
stmt_vec_info earlier_stmt_info = get_earlier_stmt (stmtinfo_a, 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)); return !DR_IS_WRITE (STMT_VINFO_DATA_REF (earlier_stmt_info));
} }
......
...@@ -3814,10 +3814,7 @@ vect_model_reduction_cost (stmt_vec_info stmt_info, internal_fn reduc_fn, ...@@ -3814,10 +3814,7 @@ vect_model_reduction_cost (stmt_vec_info stmt_info, internal_fn reduc_fn,
vectype = STMT_VINFO_VECTYPE (stmt_info); vectype = STMT_VINFO_VECTYPE (stmt_info);
mode = TYPE_MODE (vectype); mode = TYPE_MODE (vectype);
stmt_vec_info orig_stmt_info = STMT_VINFO_RELATED_STMT (stmt_info); stmt_vec_info orig_stmt_info = vect_orig_stmt (stmt_info);
if (!orig_stmt_info)
orig_stmt_info = stmt_info;
code = gimple_assign_rhs_code (orig_stmt_info->stmt); code = gimple_assign_rhs_code (orig_stmt_info->stmt);
...@@ -4738,13 +4735,8 @@ vect_create_epilog_for_reduction (vec<tree> vect_defs, ...@@ -4738,13 +4735,8 @@ vect_create_epilog_for_reduction (vec<tree> vect_defs,
Otherwise (it is a regular reduction) - the tree-code and scalar-def Otherwise (it is a regular reduction) - the tree-code and scalar-def
are taken from STMT. */ are taken from STMT. */
stmt_vec_info orig_stmt_info = STMT_VINFO_RELATED_STMT (stmt_info); stmt_vec_info orig_stmt_info = vect_orig_stmt (stmt_info);
if (!orig_stmt_info) if (orig_stmt_info != stmt_info)
{
/* Regular reduction */
orig_stmt_info = stmt_info;
}
else
{ {
/* Reduction pattern */ /* Reduction pattern */
gcc_assert (STMT_VINFO_IN_PATTERN_P (orig_stmt_info)); gcc_assert (STMT_VINFO_IN_PATTERN_P (orig_stmt_info));
...@@ -5540,11 +5532,7 @@ vect_finalize_reduction: ...@@ -5540,11 +5532,7 @@ vect_finalize_reduction:
if (REDUC_GROUP_FIRST_ELEMENT (stmt_info)) if (REDUC_GROUP_FIRST_ELEMENT (stmt_info))
{ {
stmt_vec_info dest_stmt_info stmt_vec_info dest_stmt_info
= SLP_TREE_SCALAR_STMTS (slp_node)[group_size - 1]; = vect_orig_stmt (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);
scalar_dest = gimple_assign_lhs (dest_stmt_info->stmt); scalar_dest = gimple_assign_lhs (dest_stmt_info->stmt);
group_size = 1; group_size = 1;
} }
...@@ -7898,10 +7886,8 @@ vectorizable_live_operation (stmt_vec_info stmt_info, ...@@ -7898,10 +7886,8 @@ vectorizable_live_operation (stmt_vec_info stmt_info,
return true; return true;
} }
/* If stmt has a related stmt, then use that for getting the lhs. */ /* Use the lhs of the original scalar statement. */
gimple *stmt = (is_pattern_stmt_p (stmt_info) gimple *stmt = vect_orig_stmt (stmt_info)->stmt;
? STMT_VINFO_RELATED_STMT (stmt_info)->stmt
: stmt_info->stmt);
lhs = (is_a <gphi *> (stmt)) ? gimple_phi_result (stmt) lhs = (is_a <gphi *> (stmt)) ? gimple_phi_result (stmt)
: gimple_get_lhs (stmt); : gimple_get_lhs (stmt);
......
...@@ -1848,8 +1848,7 @@ vect_find_last_scalar_stmt_in_slp (slp_tree node) ...@@ -1848,8 +1848,7 @@ vect_find_last_scalar_stmt_in_slp (slp_tree node)
for (int i = 0; SLP_TREE_SCALAR_STMTS (node).iterate (i, &stmt_vinfo); i++) for (int i = 0; SLP_TREE_SCALAR_STMTS (node).iterate (i, &stmt_vinfo); i++)
{ {
if (is_pattern_stmt_p (stmt_vinfo)) stmt_vinfo = vect_orig_stmt (stmt_vinfo);
stmt_vinfo = STMT_VINFO_RELATED_STMT (stmt_vinfo);
last = last ? get_later_stmt (stmt_vinfo, last) : stmt_vinfo; last = last ? get_later_stmt (stmt_vinfo, last) : stmt_vinfo;
} }
...@@ -2314,10 +2313,7 @@ vect_detect_hybrid_slp_stmts (slp_tree node, unsigned i, slp_vect_type stype) ...@@ -2314,10 +2313,7 @@ vect_detect_hybrid_slp_stmts (slp_tree node, unsigned i, slp_vect_type stype)
gcc_checking_assert (PURE_SLP_STMT (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 /* If we get a pattern stmt here we have to use the LHS of the
original stmt for immediate uses. */ original stmt for immediate uses. */
gimple *stmt = stmt_vinfo->stmt; gimple *stmt = vect_orig_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;
tree def; tree def;
if (gimple_code (stmt) == GIMPLE_PHI) if (gimple_code (stmt) == GIMPLE_PHI)
def = gimple_phi_result (stmt); def = gimple_phi_result (stmt);
...@@ -4087,8 +4083,7 @@ vect_schedule_slp (vec_info *vinfo) ...@@ -4087,8 +4083,7 @@ vect_schedule_slp (vec_info *vinfo)
if (!STMT_VINFO_DATA_REF (store_info)) if (!STMT_VINFO_DATA_REF (store_info))
break; break;
if (is_pattern_stmt_p (store_info)) store_info = vect_orig_stmt (store_info);
store_info = STMT_VINFO_RELATED_STMT (store_info);
/* Free the attached stmt_vec_info and remove the stmt. */ /* Free the attached stmt_vec_info and remove the stmt. */
vinfo->remove_stmt (store_info); vinfo->remove_stmt (store_info);
} }
......
...@@ -3628,8 +3628,7 @@ vectorizable_call (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi, ...@@ -3628,8 +3628,7 @@ vectorizable_call (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi,
if (slp_node) if (slp_node)
return true; return true;
if (is_pattern_stmt_p (stmt_info)) stmt_info = vect_orig_stmt (stmt_info);
stmt_info = STMT_VINFO_RELATED_STMT (stmt_info);
lhs = gimple_get_lhs (stmt_info->stmt); lhs = gimple_get_lhs (stmt_info->stmt);
gassign *new_stmt gassign *new_stmt
...@@ -4364,10 +4363,7 @@ vectorizable_simd_clone_call (stmt_vec_info stmt_info, ...@@ -4364,10 +4363,7 @@ vectorizable_simd_clone_call (stmt_vec_info stmt_info,
if (scalar_dest) if (scalar_dest)
{ {
type = TREE_TYPE (scalar_dest); type = TREE_TYPE (scalar_dest);
if (is_pattern_stmt_p (stmt_info)) lhs = gimple_call_lhs (vect_orig_stmt (stmt_info)->stmt);
lhs = gimple_call_lhs (STMT_VINFO_RELATED_STMT (stmt_info)->stmt);
else
lhs = gimple_call_lhs (stmt);
new_stmt = gimple_build_assign (lhs, build_zero_cst (type)); new_stmt = gimple_build_assign (lhs, build_zero_cst (type));
} }
else else
...@@ -9843,8 +9839,7 @@ vect_remove_stores (stmt_vec_info first_stmt_info) ...@@ -9843,8 +9839,7 @@ vect_remove_stores (stmt_vec_info first_stmt_info)
while (next_stmt_info) while (next_stmt_info)
{ {
stmt_vec_info tmp = DR_GROUP_NEXT_ELEMENT (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 = vect_orig_stmt (next_stmt_info);
next_stmt_info = STMT_VINFO_RELATED_STMT (next_stmt_info);
/* Free the attached stmt_vec_info and remove the stmt. */ /* Free the attached stmt_vec_info and remove the stmt. */
vinfo->remove_stmt (next_stmt_info); vinfo->remove_stmt (next_stmt_info);
next_stmt_info = tmp; next_stmt_info = tmp;
......
...@@ -1120,6 +1120,17 @@ is_pattern_stmt_p (stmt_vec_info stmt_info) ...@@ -1120,6 +1120,17 @@ is_pattern_stmt_p (stmt_vec_info stmt_info)
return stmt_info->pattern_stmt_p; 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. */ /* Return true if BB is a loop header. */
static inline bool static inline bool
......
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