[11/n] PR85694: Apply pattern matching to pattern definition statements
commitd5b5c2c5ad5aec3d20145eaf7105e0d73b21a8b8
authorrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 30 Jun 2018 12:48:51 +0000 (30 12:48 +0000)
committerrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 30 Jun 2018 12:48:51 +0000 (30 12:48 +0000)
tree3894044c9c2a7faa377969c5901acdaa2d748efc
parentd04bd45a41920cc86d9e5eb9ed090f54c421141c
[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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@262275 138bc75d-0d04-0410-961f-82ee72b054a4
gcc/ChangeLog
gcc/gimple-iterator.c
gcc/gimple-iterator.h
gcc/tree-vect-patterns.c