aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2019-10-28 13:42:03 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2019-10-28 13:42:03 +0000
commit97c6bea819ec0a773041308e62a7c05c33f093b0 (patch)
treefd82c1940beb67c5d5fae3fcd85d1f4ef7a94fc8 /gcc
parent14c835a01ceac44e685589489b46ffaabd034177 (diff)
downloadgcc-97c6bea819ec0a773041308e62a7c05c33f093b0.zip
gcc-97c6bea819ec0a773041308e62a7c05c33f093b0.tar.gz
gcc-97c6bea819ec0a773041308e62a7c05c33f093b0.tar.bz2
re PR tree-optimization/92241 (ice in vect_mark_pattern_st mts, at tree-vect-patterns.c:5175)
2019-10-28 Richard Biener <rguenther@suse.de> PR tree-optimization/92241 * tree-vect-loop.c (vect_fixup_scalar_cycles_with_patterns): When we failed to update the reduction index do not use the pattern stmts for the reduction chain. (vectorizable_reduction): When the reduction chain is corrupt, fail. * tree-vect-patterns.c (vect_mark_pattern_stmts): Stop when we fail to update the reduction chain. * gcc.dg/torture/pr92241.c: New testcase. From-SVN: r277516
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog11
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr92241.c13
-rw-r--r--gcc/tree-vect-loop.c19
-rw-r--r--gcc/tree-vect-patterns.c12
5 files changed, 52 insertions, 8 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index dc39bf8..9809040 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,16 @@
2019-10-28 Richard Biener <rguenther@suse.de>
+ PR tree-optimization/92241
+ * tree-vect-loop.c (vect_fixup_scalar_cycles_with_patterns): When
+ we failed to update the reduction index do not use the pattern
+ stmts for the reduction chain.
+ (vectorizable_reduction): When the reduction chain is corrupt,
+ fail.
+ * tree-vect-patterns.c (vect_mark_pattern_stmts): Stop when we
+ fail to update the reduction chain.
+
+2019-10-28 Richard Biener <rguenther@suse.de>
+
* tree-vect-loop.c (vect_create_epilog_for_reduction): Use
STMT_VINFO_REDUC_IDX from the actual stmt.
(vect_transform_reduction): Likewise.
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index c7f3af7..41dea35 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2019-10-28 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/92241
+ * gcc.dg/torture/pr92241.c: New testcase.
+
2019-10-28 Uroš Bizjak <ubizjak@gmail.com>
PR target/92225
diff --git a/gcc/testsuite/gcc.dg/torture/pr92241.c b/gcc/testsuite/gcc.dg/torture/pr92241.c
new file mode 100644
index 0000000..331d03b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr92241.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-ftree-vectorize" } */
+
+int a, b;
+char c[2];
+void d() {
+ char e;
+ for (; b; b--) {
+ e = 0;
+ for (; e <= 1; e++)
+ a &= c[b + e] && 1;
+ }
+}
diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c
index 14d072b..d11a1f9 100644
--- a/gcc/tree-vect-loop.c
+++ b/gcc/tree-vect-loop.c
@@ -689,13 +689,16 @@ vect_fixup_scalar_cycles_with_patterns (loop_vec_info loop_vinfo)
stmt_vec_info next = REDUC_GROUP_NEXT_ELEMENT (first);
while (next)
{
- if (! STMT_VINFO_IN_PATTERN_P (next))
+ if (! STMT_VINFO_IN_PATTERN_P (next)
+ || STMT_VINFO_REDUC_IDX (STMT_VINFO_RELATED_STMT (next)) == -1)
break;
next = REDUC_GROUP_NEXT_ELEMENT (next);
}
- /* If not all stmt in the chain are patterns try to handle
- the chain without patterns. */
- if (! next)
+ /* If not all stmt in the chain are patterns or if we failed
+ to update STMT_VINFO_REDUC_IDX try to handle the chain
+ without patterns. */
+ if (! next
+ && STMT_VINFO_REDUC_IDX (STMT_VINFO_RELATED_STMT (first)) != -1)
{
vect_fixup_reduc_chain (first);
LOOP_VINFO_REDUCTION_CHAINS (loop_vinfo)[i]
@@ -5730,7 +5733,13 @@ vectorizable_reduction (stmt_vec_info stmt_info, slp_tree slp_node,
{
stmt_vec_info def = loop_vinfo->lookup_def (reduc_def);
def = vect_stmt_to_vectorize (def);
- gcc_assert (STMT_VINFO_REDUC_IDX (def) != -1);
+ if (STMT_VINFO_REDUC_IDX (def) == -1)
+ {
+ if (dump_enabled_p ())
+ dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+ "reduction chain broken by patterns.\n");
+ return false;
+ }
if (!REDUC_GROUP_FIRST_ELEMENT (def))
only_slp_reduc_chain = false;
reduc_def = gimple_op (def->stmt, 1 + STMT_VINFO_REDUC_IDX (def));
diff --git a/gcc/tree-vect-patterns.c b/gcc/tree-vect-patterns.c
index 31e9e2a..c0fdde6 100644
--- a/gcc/tree-vect-patterns.c
+++ b/gcc/tree-vect-patterns.c
@@ -5110,6 +5110,9 @@ vect_mark_pattern_stmts (stmt_vec_info orig_stmt_info, gimple *pattern_stmt,
for (gimple_stmt_iterator si = gsi_start (def_seq);
!gsi_end_p (si); gsi_next (&si))
{
+ if (dump_enabled_p ())
+ dump_printf_loc (MSG_NOTE, vect_location,
+ "extra pattern stmt: %G", gsi_stmt (si));
stmt_vec_info pattern_stmt_info
= vect_init_pattern_stmt (gsi_stmt (si),
orig_stmt_info, pattern_vectype);
@@ -5169,10 +5172,13 @@ vect_mark_pattern_stmts (stmt_vec_info orig_stmt_info, gimple *pattern_stmt,
found = true;
break;
}
- if (found && s == pattern_stmt)
- break;
if (s == pattern_stmt)
- gcc_unreachable ();
+ {
+ if (!found && dump_enabled_p ())
+ dump_printf_loc (MSG_NOTE, vect_location,
+ "failed to update reduction index.\n");
+ break;
+ }
if (gsi_end_p (si))
s = pattern_stmt;
else