Commit e3947d80 by Richard Sandiford Committed by Richard Sandiford

[2/n] PR85694: Attach a DEF_SEQ only to the original statement

A pattern's PATTERN_DEF_SEQ was attached to both the original statement
and the main pattern statement, which made it harder to update later.
This patch attaches it to just the original statement.  In practice,
anything that cared had ready access to both.

2018-06-20  Richard Sandiford  <richard.sandiford@arm.com>

gcc/
	* tree-vectorizer.h (_stmt_vec_info): Note above pattern_def_seq
	that the sequence is attached to the original statement rather
	than the pattern statement.
	* tree-vect-loop.c (vect_determine_vf_for_stmt): Take the
	PATTERN_DEF_SEQ from the original statement rather than
	the main pattern statement.
	* tree-vect-stmts.c (free_stmt_vec_info): Likewise.
	* tree-vect-patterns.c (vect_recog_dot_prod_pattern): Likewise.
	(vect_mark_pattern_stmts): Don't copy the PATTERN_DEF_SEQ.

From-SVN: r261785
parent d54a098e
2018-06-20 Richard Sandiford <richard.sandiford@arm.com> 2018-06-20 Richard Sandiford <richard.sandiford@arm.com>
* tree-vectorizer.h (_stmt_vec_info): Note above pattern_def_seq
that the sequence is attached to the original statement rather
than the pattern statement.
* tree-vect-loop.c (vect_determine_vf_for_stmt): Take the
PATTERN_DEF_SEQ from the original statement rather than
the main pattern statement.
* tree-vect-stmts.c (free_stmt_vec_info): Likewise.
* tree-vect-patterns.c (vect_recog_dot_prod_pattern): Likewise.
(vect_mark_pattern_stmts): Don't copy the PATTERN_DEF_SEQ.
2018-06-20 Richard Sandiford <richard.sandiford@arm.com>
* tree-vect-stmts.c (vect_analyze_stmt): Move the handling of pattern * tree-vect-stmts.c (vect_analyze_stmt): Move the handling of pattern
definition statements before the early exit for statements that aren't definition statements before the early exit for statements that aren't
live or relevant. live or relevant.
......
...@@ -224,10 +224,10 @@ vect_determine_vf_for_stmt (stmt_vec_info stmt_info, poly_uint64 *vf, ...@@ -224,10 +224,10 @@ vect_determine_vf_for_stmt (stmt_vec_info stmt_info, poly_uint64 *vf,
if (STMT_VINFO_IN_PATTERN_P (stmt_info) if (STMT_VINFO_IN_PATTERN_P (stmt_info)
&& STMT_VINFO_RELATED_STMT (stmt_info)) && STMT_VINFO_RELATED_STMT (stmt_info))
{ {
gimple *pattern_def_seq = STMT_VINFO_PATTERN_DEF_SEQ (stmt_info);
stmt_info = vinfo_for_stmt (STMT_VINFO_RELATED_STMT (stmt_info)); stmt_info = vinfo_for_stmt (STMT_VINFO_RELATED_STMT (stmt_info));
/* If a pattern statement has def stmts, analyze them too. */ /* If a pattern statement has def stmts, analyze them too. */
gimple *pattern_def_seq = STMT_VINFO_PATTERN_DEF_SEQ (stmt_info);
for (gimple_stmt_iterator si = gsi_start (pattern_def_seq); for (gimple_stmt_iterator si = gsi_start (pattern_def_seq);
!gsi_end_p (si); gsi_next (&si)) !gsi_end_p (si); gsi_next (&si))
{ {
...@@ -2247,10 +2247,10 @@ again: ...@@ -2247,10 +2247,10 @@ again:
STMT_SLP_TYPE (stmt_info) = loop_vect; STMT_SLP_TYPE (stmt_info) = loop_vect;
if (STMT_VINFO_IN_PATTERN_P (stmt_info)) if (STMT_VINFO_IN_PATTERN_P (stmt_info))
{ {
gimple *pattern_def_seq = STMT_VINFO_PATTERN_DEF_SEQ (stmt_info);
stmt_info = vinfo_for_stmt (STMT_VINFO_RELATED_STMT (stmt_info)); stmt_info = vinfo_for_stmt (STMT_VINFO_RELATED_STMT (stmt_info));
STMT_SLP_TYPE (stmt_info) = loop_vect; STMT_SLP_TYPE (stmt_info) = loop_vect;
for (gimple_stmt_iterator pi for (gimple_stmt_iterator pi = gsi_start (pattern_def_seq);
= gsi_start (STMT_VINFO_PATTERN_DEF_SEQ (stmt_info));
!gsi_end_p (pi); gsi_next (&pi)) !gsi_end_p (pi); gsi_next (&pi))
{ {
gimple *pstmt = gsi_stmt (pi); gimple *pstmt = gsi_stmt (pi);
......
...@@ -405,13 +405,13 @@ vect_recog_dot_prod_pattern (vec<gimple *> *stmts, tree *type_in, ...@@ -405,13 +405,13 @@ vect_recog_dot_prod_pattern (vec<gimple *> *stmts, tree *type_in,
stmt = STMT_VINFO_RELATED_STMT (stmt_vinfo); stmt = STMT_VINFO_RELATED_STMT (stmt_vinfo);
if (gimple_assign_rhs_code (stmt) != WIDEN_MULT_EXPR) if (gimple_assign_rhs_code (stmt) != WIDEN_MULT_EXPR)
return NULL; return NULL;
STMT_VINFO_PATTERN_DEF_SEQ (vinfo_for_stmt (last_stmt))
= STMT_VINFO_PATTERN_DEF_SEQ (stmt_vinfo);
stmt_vinfo = vinfo_for_stmt (stmt); stmt_vinfo = vinfo_for_stmt (stmt);
gcc_assert (stmt_vinfo); gcc_assert (stmt_vinfo);
gcc_assert (STMT_VINFO_DEF_TYPE (stmt_vinfo) == vect_internal_def); gcc_assert (STMT_VINFO_DEF_TYPE (stmt_vinfo) == vect_internal_def);
oprnd00 = gimple_assign_rhs1 (stmt); oprnd00 = gimple_assign_rhs1 (stmt);
oprnd01 = gimple_assign_rhs2 (stmt); oprnd01 = gimple_assign_rhs2 (stmt);
STMT_VINFO_PATTERN_DEF_SEQ (vinfo_for_stmt (last_stmt))
= STMT_VINFO_PATTERN_DEF_SEQ (stmt_vinfo);
} }
else else
{ {
...@@ -4433,28 +4433,23 @@ vect_mark_pattern_stmts (gimple *orig_stmt, gimple *pattern_stmt, ...@@ -4433,28 +4433,23 @@ vect_mark_pattern_stmts (gimple *orig_stmt, gimple *pattern_stmt,
STMT_VINFO_VECTYPE (pattern_stmt_info) = pattern_vectype; STMT_VINFO_VECTYPE (pattern_stmt_info) = pattern_vectype;
STMT_VINFO_IN_PATTERN_P (orig_stmt_info) = true; STMT_VINFO_IN_PATTERN_P (orig_stmt_info) = true;
STMT_VINFO_RELATED_STMT (orig_stmt_info) = pattern_stmt; STMT_VINFO_RELATED_STMT (orig_stmt_info) = pattern_stmt;
STMT_VINFO_PATTERN_DEF_SEQ (pattern_stmt_info) if (gimple *def_seq = STMT_VINFO_PATTERN_DEF_SEQ (orig_stmt_info))
= STMT_VINFO_PATTERN_DEF_SEQ (orig_stmt_info); for (gimple_stmt_iterator si = gsi_start (def_seq);
if (STMT_VINFO_PATTERN_DEF_SEQ (pattern_stmt_info)) !gsi_end_p (si); gsi_next (&si))
{ {
gimple_stmt_iterator si; def_stmt = gsi_stmt (si);
for (si = gsi_start (STMT_VINFO_PATTERN_DEF_SEQ (pattern_stmt_info)); def_stmt_info = vinfo_for_stmt (def_stmt);
!gsi_end_p (si); gsi_next (&si)) if (def_stmt_info == NULL)
{ {
def_stmt = gsi_stmt (si); def_stmt_info = new_stmt_vec_info (def_stmt, vinfo);
def_stmt_info = vinfo_for_stmt (def_stmt); set_vinfo_for_stmt (def_stmt, def_stmt_info);
if (def_stmt_info == NULL) }
{ gimple_set_bb (def_stmt, gimple_bb (orig_stmt));
def_stmt_info = new_stmt_vec_info (def_stmt, vinfo); STMT_VINFO_RELATED_STMT (def_stmt_info) = orig_stmt;
set_vinfo_for_stmt (def_stmt, def_stmt_info); STMT_VINFO_DEF_TYPE (def_stmt_info) = vect_internal_def;
} if (STMT_VINFO_VECTYPE (def_stmt_info) == NULL_TREE)
gimple_set_bb (def_stmt, gimple_bb (orig_stmt)); STMT_VINFO_VECTYPE (def_stmt_info) = pattern_vectype;
STMT_VINFO_RELATED_STMT (def_stmt_info) = orig_stmt; }
STMT_VINFO_DEF_TYPE (def_stmt_info) = vect_internal_def;
if (STMT_VINFO_VECTYPE (def_stmt_info) == NULL_TREE)
STMT_VINFO_VECTYPE (def_stmt_info) = pattern_vectype;
}
}
} }
/* Function vect_pattern_recog_1 /* Function vect_pattern_recog_1
......
...@@ -9876,29 +9876,26 @@ free_stmt_vec_info (gimple *stmt) ...@@ -9876,29 +9876,26 @@ free_stmt_vec_info (gimple *stmt)
too. */ too. */
if (STMT_VINFO_IN_PATTERN_P (stmt_info)) if (STMT_VINFO_IN_PATTERN_P (stmt_info))
{ {
if (gimple_seq seq = STMT_VINFO_PATTERN_DEF_SEQ (stmt_info))
for (gimple_stmt_iterator si = gsi_start (seq);
!gsi_end_p (si); gsi_next (&si))
{
gimple *seq_stmt = gsi_stmt (si);
gimple_set_bb (seq_stmt, NULL);
tree lhs = gimple_get_lhs (seq_stmt);
if (lhs && TREE_CODE (lhs) == SSA_NAME)
release_ssa_name (lhs);
free_stmt_vec_info (seq_stmt);
}
stmt_vec_info patt_info stmt_vec_info patt_info
= vinfo_for_stmt (STMT_VINFO_RELATED_STMT (stmt_info)); = vinfo_for_stmt (STMT_VINFO_RELATED_STMT (stmt_info));
if (patt_info) if (patt_info)
{ {
gimple_seq seq = STMT_VINFO_PATTERN_DEF_SEQ (patt_info);
gimple *patt_stmt = STMT_VINFO_STMT (patt_info); gimple *patt_stmt = STMT_VINFO_STMT (patt_info);
gimple_set_bb (patt_stmt, NULL); gimple_set_bb (patt_stmt, NULL);
tree lhs = gimple_get_lhs (patt_stmt); tree lhs = gimple_get_lhs (patt_stmt);
if (lhs && TREE_CODE (lhs) == SSA_NAME) if (lhs && TREE_CODE (lhs) == SSA_NAME)
release_ssa_name (lhs); release_ssa_name (lhs);
if (seq)
{
gimple_stmt_iterator si;
for (si = gsi_start (seq); !gsi_end_p (si); gsi_next (&si))
{
gimple *seq_stmt = gsi_stmt (si);
gimple_set_bb (seq_stmt, NULL);
lhs = gimple_get_lhs (seq_stmt);
if (lhs && TREE_CODE (lhs) == SSA_NAME)
release_ssa_name (lhs);
free_stmt_vec_info (seq_stmt);
}
}
free_stmt_vec_info (patt_stmt); free_stmt_vec_info (patt_stmt);
} }
} }
......
...@@ -796,7 +796,9 @@ typedef struct _stmt_vec_info { ...@@ -796,7 +796,9 @@ typedef struct _stmt_vec_info {
pattern). */ pattern). */
gimple *related_stmt; gimple *related_stmt;
/* Used to keep a sequence of def stmts of a pattern stmt if such exists. */ /* Used to keep a sequence of def stmts of a pattern stmt if such exists.
The sequence is attached to the original statement rather than the
pattern statement. */
gimple_seq pattern_def_seq; gimple_seq pattern_def_seq;
/* List of datarefs that are known to have the same alignment as the dataref /* List of datarefs that are known to have the same alignment as the dataref
......
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