aboutsummaryrefslogtreecommitdiff
path: root/gcc/gimple-iterator.c
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@arm.com>2018-06-30 12:48:51 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2018-06-30 12:48:51 +0000
commit41949de9de0c8ebabb7adb2701e775ecd671aa72 (patch)
tree3894044c9c2a7faa377969c5901acdaa2d748efc /gcc/gimple-iterator.c
parent7b98e98a98c95029434200cdfc5ad87e204d79b4 (diff)
downloadgcc-41949de9de0c8ebabb7adb2701e775ecd671aa72.zip
gcc-41949de9de0c8ebabb7adb2701e775ecd671aa72.tar.gz
gcc-41949de9de0c8ebabb7adb2701e775ecd671aa72.tar.bz2
[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
Diffstat (limited to 'gcc/gimple-iterator.c')
-rw-r--r--gcc/gimple-iterator.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/gcc/gimple-iterator.c b/gcc/gimple-iterator.c
index 4588ab0..c0131f3 100644
--- a/gcc/gimple-iterator.c
+++ b/gcc/gimple-iterator.c
@@ -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