aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2019-11-04 10:08:22 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2019-11-04 10:08:22 +0000
commitb76f4e6c06bd494d2383c4c16d1e1a034da74641 (patch)
tree72040d9a3dae2290361c6d5dee0b6c016c567d12 /gcc
parent12fd2ec5ae30207e3107eca0fea45e3b5713e26b (diff)
downloadgcc-b76f4e6c06bd494d2383c4c16d1e1a034da74641.zip
gcc-b76f4e6c06bd494d2383c4c16d1e1a034da74641.tar.gz
gcc-b76f4e6c06bd494d2383c4c16d1e1a034da74641.tar.bz2
re PR bootstrap/92301 (Wrong vectorizer code since r277566)
2019-11-04 Richard Biener <rguenther@suse.de> PR tree-optimization/92301 * tree-vect-stmts.c (process_use): Force reduction PHI defs live as required by epilogue generation * gcc.dg/pr92301.c: New testcase. From-SVN: r277771
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/pr92301.c35
-rw-r--r--gcc/tree-vect-stmts.c16
4 files changed, 62 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 418c379..5807a69 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2019-11-04 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/92301
+ * tree-vect-stmts.c (process_use): Force reduction PHI defs live
+ as required by epilogue generation
+
2019-11-04 Martin Liska <mliska@suse.cz>
PR ipa/92304
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 13acfbb..7140f1d 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2019-11-04 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/92301
+ * gcc.dg/pr92301.c: New testcase.
+
2019-11-03 Martin Sebor <msebor@redhat.com>
PR c++/88565
diff --git a/gcc/testsuite/gcc.dg/pr92301.c b/gcc/testsuite/gcc.dg/pr92301.c
new file mode 100644
index 0000000..9a47e12
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr92301.c
@@ -0,0 +1,35 @@
+/* { dg-do run } */
+/* { dg-options "-O3" } */
+
+unsigned int m;
+
+#define N 128
+unsigned int a[N];
+
+unsigned int
+__attribute__((noipa))
+df_count_refs (_Bool include_defs)
+{
+ int size = 0;
+
+ for (unsigned int regno = 0; regno < m; regno++)
+ if (include_defs)
+ size += a[regno];
+ return size;
+}
+
+int main(int argc, char **argv)
+{
+ for (unsigned i = 0; i < N; i++)
+ a[i] = i;
+
+ if (argc == 1)
+ m = 17;
+
+ unsigned int r = df_count_refs(1);
+ __builtin_printf ("r: %d\n", r);
+ if (r != 136)
+ __builtin_abort ();
+
+ return 0;
+}
diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c
index 7f52282..3cda888 100644
--- a/gcc/tree-vect-stmts.c
+++ b/gcc/tree-vect-stmts.c
@@ -475,6 +475,22 @@ process_use (stmt_vec_info stmt_vinfo, tree use, loop_vec_info loop_vinfo,
basic_block def_bb = gimple_bb (dstmt_vinfo->stmt);
basic_block bb = gimple_bb (stmt_vinfo->stmt);
+ /* case 2: A reduction phi (STMT) defined by a reduction stmt (DSTMT_VINFO).
+ We have to force the stmt live since the epilogue loop needs it to
+ continue computing the reduction. */
+ if (gimple_code (stmt_vinfo->stmt) == GIMPLE_PHI
+ && STMT_VINFO_DEF_TYPE (stmt_vinfo) == vect_reduction_def
+ && gimple_code (dstmt_vinfo->stmt) != GIMPLE_PHI
+ && STMT_VINFO_DEF_TYPE (dstmt_vinfo) == vect_reduction_def
+ && bb->loop_father == def_bb->loop_father)
+ {
+ if (dump_enabled_p ())
+ dump_printf_loc (MSG_NOTE, vect_location,
+ "reduc-stmt defining reduc-phi in the same nest.\n");
+ vect_mark_relevant (worklist, dstmt_vinfo, relevant, true);
+ return opt_result::success ();
+ }
+
/* case 3a: outer-loop stmt defining an inner-loop stmt:
outer-loop-header-bb:
d = dstmt_vinfo