aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuri Rumyantsev <ysrumyan@gmail.com>2015-10-13 13:08:31 +0000
committerIlya Enkovich <enkovich.gnu@gmail.com>2015-10-13 13:08:31 +0000
commit85e46be3344c0124766ce6cc21cd23ce36cb149b (patch)
tree3a3fb504ba5df97bcda16929a164ffb73bef27ed
parent4f6f9475f810a93fc0157a886ca598320313cbc3 (diff)
gcc/
2014-10-13 Yuri Rumyantsev <ysrumyan@gmail.com> PR tree-optimization/67909, 67947 * tree-ssa-loop-unswitch.c (find_loop_guard): Add check that GUARD_EDGE really skip the inner loop. gcc/testsuite/ 2014-10-13 Yuri Rumyantsev <ysrumyan@gmail.com> PR tree-optimization/67909, 67947 * gcc.dg/torture/pr67947.c: New test. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@228760 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr67947.c30
-rw-r--r--gcc/tree-ssa-loop-unswitch.c11
4 files changed, 51 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index caab5338ff6..68461a0a575 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2014-10-13 Yuri Rumyantsev <ysrumyan@gmail.com>
+
+ PR tree-optimization/67909, 67947
+ * tree-ssa-loop-unswitch.c (find_loop_guard): Add check that GUARD_EDGE
+ really skip the inner loop.
+
2015-10-13 Jeff Law <law@redhat.com>
* tree-ssa-threadbackward.c (fsm_find_control_statement_thread_paths):
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index acf6df53b94..523b684e8ed 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2014-10-13 Yuri Rumyantsev <ysrumyan@gmail.com>
+
+ PR tree-optimization/67909, 67947
+ * gcc.dg/torture/pr67947.c: New test.
+
2015-10-13 Jeff Law <law@redhat.com>
* gcc.dg/tree-ssa/ssa-thread-13.c: New test.
diff --git a/gcc/testsuite/gcc.dg/torture/pr67947.c b/gcc/testsuite/gcc.dg/torture/pr67947.c
new file mode 100644
index 00000000000..5664c48390a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr67947.c
@@ -0,0 +1,30 @@
+/* { dg-additional-options "-O3" } */
+
+#include <stdlib.h>
+
+int a;
+int c;
+__attribute__((noinline, noclone)) void foo (int x)
+{
+ if (x == 0)
+ c++;
+}
+
+int
+main (int argc, char* argv[])
+{
+ int j, k, b = 0;
+ if (argc == 0)
+ b = 1;
+ for (j = 0; j < 3; j++)
+ for (k = 0; k < 1; k++)
+ {
+ foo (0);
+ if (b)
+ for (k = -1; a;)
+ ;
+ }
+ if (c != 3)
+ abort ();
+ return 0;
+}
diff --git a/gcc/tree-ssa-loop-unswitch.c b/gcc/tree-ssa-loop-unswitch.c
index d6faa378ba8..2edc00031c6 100644
--- a/gcc/tree-ssa-loop-unswitch.c
+++ b/gcc/tree-ssa-loop-unswitch.c
@@ -471,7 +471,6 @@ find_loop_guard (struct loop *loop)
{
basic_block header = loop->header;
edge guard_edge, te, fe;
- /* bitmap processed, known_invariants;*/
basic_block *body = NULL;
unsigned i;
tree use;
@@ -529,6 +528,16 @@ find_loop_guard (struct loop *loop)
else
return NULL;
+ /* Guard edge must skip inner loop. */
+ if (!dominated_by_p (CDI_DOMINATORS, loop->inner->header,
+ guard_edge == fe ? te->dest : fe->dest))
+ {
+ if (dump_file && (dump_flags & TDF_DETAILS))
+ fprintf (dump_file, "Guard edge %d --> %d is not around the loop!\n",
+ guard_edge->src->index, guard_edge->dest->index);
+ return NULL;
+ }
+
if (dump_file && (dump_flags & TDF_DETAILS))
fprintf (dump_file,
"Considering guard %d -> %d in loop %d\n",