aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2019-11-05 16:12:07 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2019-11-05 16:12:07 +0000
commit02bf7e6fa219f939b3225c54fbe8bab2133b1aeb (patch)
treef478ba0da318ede08b7f8bdd8b92bcb5c399f550 /gcc
parentc6a7be9bdadf67dcc5496222129acadbb2dd0610 (diff)
downloadgcc-02bf7e6fa219f939b3225c54fbe8bab2133b1aeb.zip
gcc-02bf7e6fa219f939b3225c54fbe8bab2133b1aeb.tar.gz
gcc-02bf7e6fa219f939b3225c54fbe8bab2133b1aeb.tar.bz2
re PR tree-optimization/92371 (ICE in info_for_reduction, at tree-vect-loop.c:4106)
2019-11-05 Richard Biener <rguenther@suse.de> PR tree-optimization/92371 * tree-vect-loop.c (vectorizable_reduction): Set STMT_VINFO_REDUC_DEF on the original stmt of live stmts in the chain. (vectorizable_live_operation): Look at the original stmt when checking STMT_VINFO_REDUC_DEF. * gcc.dg/torture/pr92371.c: New testcase. From-SVN: r277850
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr92371.c12
-rw-r--r--gcc/tree-vect-loop.c15
4 files changed, 33 insertions, 7 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index d5e0f61..21304fd 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2019-11-05 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/92371
+ * tree-vect-loop.c (vectorizable_reduction): Set STMT_VINFO_REDUC_DEF
+ on the original stmt of live stmts in the chain.
+ (vectorizable_live_operation): Look at the original stmt when
+ checking STMT_VINFO_REDUC_DEF.
+
2019-11-05 Aldy Hernandez <aldyh@redhat.com>
* gimple-fold.c, gimple-loop-versioning.cc,
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index a148816..725cfa5 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2019-11-05 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/92371
+ * gcc.dg/torture/pr92371.c: New testcase.
+
2019-11-05 Martin Liska <mliska@suse.cz>
* c-c++-common/ubsan/ptr-overflow-2.c: Update based on changed
diff --git a/gcc/testsuite/gcc.dg/torture/pr92371.c b/gcc/testsuite/gcc.dg/torture/pr92371.c
new file mode 100644
index 0000000..0c78d32
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr92371.c
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-ftree-vectorize" } */
+
+int a, b;
+void d()
+{
+ int c = sizeof(int);
+ for (; a; a++)
+ c *= sizeof(int);
+ c *= sizeof(int);
+ b = c;
+}
diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c
index 3448b55..a63f8d5 100644
--- a/gcc/tree-vect-loop.c
+++ b/gcc/tree-vect-loop.c
@@ -5836,21 +5836,22 @@ vectorizable_reduction (stmt_vec_info stmt_info, slp_tree slp_node,
while (reduc_def != PHI_RESULT (reduc_def_phi))
{
stmt_vec_info def = loop_vinfo->lookup_def (reduc_def);
- def = vect_stmt_to_vectorize (def);
- if (STMT_VINFO_REDUC_IDX (def) == -1)
+ stmt_vec_info vdef = vect_stmt_to_vectorize (def);
+ if (STMT_VINFO_REDUC_IDX (vdef) == -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))
+ if (!REDUC_GROUP_FIRST_ELEMENT (vdef))
only_slp_reduc_chain = false;
/* ??? For epilogue generation live members of the chain need
- to point back to the PHI for info_for_reduction to work. */
- if (STMT_VINFO_LIVE_P (def))
+ to point back to the PHI via their original stmt for
+ info_for_reduction to work. */
+ if (STMT_VINFO_LIVE_P (vdef))
STMT_VINFO_REDUC_DEF (def) = phi_info;
- reduc_def = gimple_op (def->stmt, 1 + STMT_VINFO_REDUC_IDX (def));
+ reduc_def = gimple_op (vdef->stmt, 1 + STMT_VINFO_REDUC_IDX (vdef));
reduc_chain_length++;
}
@@ -7554,7 +7555,7 @@ vectorizable_live_operation (stmt_vec_info stmt_info,
/* If a stmt of a reduction is live, vectorize it via
vect_create_epilog_for_reduction. vectorizable_reduction assessed
validity so just trigger the transform here. */
- if (STMT_VINFO_REDUC_DEF (stmt_info))
+ if (STMT_VINFO_REDUC_DEF (vect_orig_stmt (stmt_info)))
{
if (!vec_stmt_p)
return true;