summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2017-07-25 11:02:32 +0000
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2017-07-25 11:02:32 +0000
commit4364527a82e67d3f1468c6c964a4cc3016edbd21 (patch)
treed8422d939914316f82a4becf678760077bcbcf77
parentb622227ef113580a3608987e698eb543b2f36447 (diff)
downloadgcc-4364527a82e67d3f1468c6c964a4cc3016edbd21.tar.gz
2017-07-25 Richard Biener <rguenther@suse.de>
PR tree-optimization/81510 * tree-vect-loop.c (vect_is_simple_reduction): When the reduction stmt is not inside the loop bail out. * gcc.dg/torture/pr81510.c: New testcase. * gcc.dg/torture/pr81510-2.c: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@250504 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr81510-2.c19
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr81510.c29
-rw-r--r--gcc/tree-vect-loop.c40
5 files changed, 81 insertions, 19 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 82c7edc595d..880b10e2955 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,11 @@
2017-07-25 Richard Biener <rguenther@suse.de>
+ PR tree-optimization/81510
+ * tree-vect-loop.c (vect_is_simple_reduction): When the
+ reduction stmt is not inside the loop bail out.
+
+2017-07-25 Richard Biener <rguenther@suse.de>
+
PR tree-optimization/81303
* tree-vect-loop-manip.c (vect_loop_versioning): Build
profitability check against LOOP_VINFO_NITERSM1.
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 2762ae5b70f..f75186947ad 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2017-07-25 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/81510
+ * gcc.dg/torture/pr81510.c: New testcase.
+ * gcc.dg/torture/pr81510-2.c: Likewise.
+
2017-07-25 Martin Liska <mliska@suse.cz>
PR ipa/81520
diff --git a/gcc/testsuite/gcc.dg/torture/pr81510-2.c b/gcc/testsuite/gcc.dg/torture/pr81510-2.c
new file mode 100644
index 00000000000..7e2bc9866f7
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr81510-2.c
@@ -0,0 +1,19 @@
+/* { dg-do compile } */
+
+typedef int h;
+typedef int k;
+int a;
+int b;
+int c;
+int d;
+int e;
+int f(int g)
+{
+ h *i = &e;
+ k *j;
+ if (d -= b)
+ for (; *j; *j += 1) {
+ g = g || (a = e ? c = (__UINTPTR_TYPE__)j : 0) + *i;
+ i = &d;
+ }
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr81510.c b/gcc/testsuite/gcc.dg/torture/pr81510.c
new file mode 100644
index 00000000000..c93c4683629
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr81510.c
@@ -0,0 +1,29 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-w" } */
+
+typedef int d;
+typedef int f;
+typedef long h;
+int a;
+int b;
+int c;
+int e()
+{
+ f *g;
+ h i;
+ for (;;)
+ if (g)
+ for (; b; b++) {
+ g = c;
+ if (a &= c) {
+ d *j = &b;
+ h k;
+ for (; i; i++) {
+ *g ?: (*j = k);
+ g = &a;
+ }
+ for (; i <= 3; i++)
+ ;
+ }
+ }
+}
diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c
index 931f1b5872e..5b1b8a1fdee 100644
--- a/gcc/tree-vect-loop.c
+++ b/gcc/tree-vect-loop.c
@@ -2813,27 +2813,29 @@ vect_is_simple_reduction (loop_vec_info loop_info, gimple *phi,
return NULL;
}
+ if (! flow_bb_inside_loop_p (loop, gimple_bb (def_stmt)))
+ return NULL;
+
nloop_uses = 0;
auto_vec<gphi *, 3> lcphis;
- if (flow_bb_inside_loop_p (loop, gimple_bb (def_stmt)))
- FOR_EACH_IMM_USE_FAST (use_p, imm_iter, name)
- {
- gimple *use_stmt = USE_STMT (use_p);
- if (is_gimple_debug (use_stmt))
- continue;
- if (flow_bb_inside_loop_p (loop, gimple_bb (use_stmt)))
- nloop_uses++;
- else
- /* We can have more than one loop-closed PHI. */
- lcphis.safe_push (as_a <gphi *> (use_stmt));
- if (nloop_uses > 1)
- {
- if (dump_enabled_p ())
- dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
- "reduction used in loop.\n");
- return NULL;
- }
- }
+ FOR_EACH_IMM_USE_FAST (use_p, imm_iter, name)
+ {
+ gimple *use_stmt = USE_STMT (use_p);
+ if (is_gimple_debug (use_stmt))
+ continue;
+ if (flow_bb_inside_loop_p (loop, gimple_bb (use_stmt)))
+ nloop_uses++;
+ else
+ /* We can have more than one loop-closed PHI. */
+ lcphis.safe_push (as_a <gphi *> (use_stmt));
+ if (nloop_uses > 1)
+ {
+ if (dump_enabled_p ())
+ dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+ "reduction used in loop.\n");
+ return NULL;
+ }
+ }
/* If DEF_STMT is a phi node itself, we expect it to have a single argument
defined in the inner loop. */