Commit 41949de9 by Richard Sandiford Committed by Richard Sandiford

[11/n] PR85694: Apply pattern matching to pattern definition statements

Although the first pattern match wins in the sense that no later
function can match the *old* gimple statement, it still seems worth
letting them match the *new* gimple statements, just like we would if
the original IR had included that sequence from the outset.

This is mostly true after the later patch for PR85694, where e.g. we
could recognise:

   signed char a;
   int ap = (int) a;
   int res = ap * 3;

as the pattern:

   short ap' = (short) a;
   short res = ap' * 3;     // S1: definition statement
   int res = (int) res;     // S2: pattern statement

and then apply the mult pattern to "ap' * 3".  The patch needs to
come first (without its own test cases) so that the main over-widening
patch doesn't regress anything.

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

gcc/
	* gimple-iterator.c (gsi_for_stmt): Add a new overload that takes
	the containing gimple_seq *.
	* gimple-iterator.h (gsi_for_stmt): Declare it.
	* tree-vect-patterns.c (vect_recog_dot_prod_pattern)
	(vect_recog_sad_pattern, vect_recog_widen_sum_pattern)
	(vect_recog_widen_shift_pattern, vect_recog_rotate_pattern)
	(vect_recog_vector_vector_shift_pattern, vect_recog_divmod_pattern)
	(vect_recog_mask_conversion_pattern): Remove STMT_VINFO_IN_PATTERN_P
	checks.
	(vect_init_pattern_stmt, vect_set_pattern_stmt): New functions,
	split out from...
	(vect_mark_pattern_stmts): ...here.  Handle cases in which the
	statement being replaced is part of an existing pattern
	definition sequence, inserting the new pattern statements before
	the original one.
	(vect_pattern_recog_1): Don't return a bool.  If the statement
	is already part of a pattern, instead apply pattern matching
	to the pattern definition statements.  Don't clear the
	STMT_VINFO_RELATED_STMT if is_pattern_stmt_p.
	(vect_pattern_recog): Don't break after the first match;
	continue processing the pattern definition statements instead.
	Don't bail out for STMT_VINFO_IN_PATTERN_P here.

From-SVN: r262275
parent 7b98e98a
2018-06-30 Richard Sandiford <richard.sandiford@arm.com>
* gimple-iterator.c (gsi_for_stmt): Add a new overload that takes
the containing gimple_seq *.
* gimple-iterator.h (gsi_for_stmt): Declare it.
* tree-vect-patterns.c (vect_recog_dot_prod_pattern)
(vect_recog_sad_pattern, vect_recog_widen_sum_pattern)
(vect_recog_widen_shift_pattern, vect_recog_rotate_pattern)
(vect_recog_vector_vector_shift_pattern, vect_recog_divmod_pattern)
(vect_recog_mask_conversion_pattern): Remove STMT_VINFO_IN_PATTERN_P
checks.
(vect_init_pattern_stmt, vect_set_pattern_stmt): New functions,
split out from...
(vect_mark_pattern_stmts): ...here. Handle cases in which the
statement being replaced is part of an existing pattern
definition sequence, inserting the new pattern statements before
the original one.
(vect_pattern_recog_1): Don't return a bool. If the statement
is already part of a pattern, instead apply pattern matching
to the pattern definition statements. Don't clear the
STMT_VINFO_RELATED_STMT if is_pattern_stmt_p.
(vect_pattern_recog): Don't break after the first match;
continue processing the pattern definition statements instead.
Don't bail out for STMT_VINFO_IN_PATTERN_P here.
2018-06-30 Richard Sandiford <richard.sandiford@arm.com>
* tree-vect-patterns.c (vect_reassociating_reduction_p): New function.
(vect_recog_dot_prod_pattern, vect_recog_sad_pattern)
(vect_recog_widen_sum_pattern): Use it.
......
......@@ -619,6 +619,18 @@ gsi_for_stmt (gimple *stmt)
return i;
}
/* Get an iterator for STMT, which is known to belong to SEQ. This is
equivalent to starting at the beginning of SEQ and searching forward
until STMT is found. */
gimple_stmt_iterator
gsi_for_stmt (gimple *stmt, gimple_seq *seq)
{
gimple_stmt_iterator i = gsi_start_1 (seq);
i.ptr = stmt;
return i;
}
/* Finds iterator for PHI. */
gphi_iterator
......
......@@ -79,6 +79,7 @@ extern void gsi_insert_after (gimple_stmt_iterator *, gimple *,
enum gsi_iterator_update);
extern bool gsi_remove (gimple_stmt_iterator *, bool);
extern gimple_stmt_iterator gsi_for_stmt (gimple *);
extern gimple_stmt_iterator gsi_for_stmt (gimple *, gimple_seq *);
extern gphi_iterator gsi_for_phi (gphi *);
extern void gsi_move_after (gimple_stmt_iterator *, gimple_stmt_iterator *);
extern void gsi_move_before (gimple_stmt_iterator *, gimple_stmt_iterator *);
......
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