From 9a56d038aebc6b873971dc0921470fdfad9d0988 Mon Sep 17 00:00:00 2001 From: rguenth Date: Thu, 3 May 2018 13:20:02 +0000 Subject: [PATCH] 2018-05-03 Richard Biener PR tree-optimization/85615 * tree-ssa-threadupdate.c (thread_block_1): Only allow exits to loops not nested in BBs loop father to avoid creating multi-entry loops. * gcc.dg/torture/pr85615.c: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@259891 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 7 +++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/torture/pr85615.c | 28 ++++++++++++++++++++++++++++ gcc/tree-ssa-threadupdate.c | 4 +++- 4 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/torture/pr85615.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3ce8273a499..893a459e09a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2018-05-03 Richard Biener + + PR tree-optimization/85615 + * tree-ssa-threadupdate.c (thread_block_1): Only allow exits + to loops not nested in BBs loop father to avoid creating multi-entry + loops. + 2018-05-03 Kyrylo Tkachov PR tree-optimization/70291 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3a69665dd69..6d135894c27 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-05-03 Richard Biener + + PR tree-optimization/85615 + * gcc.dg/torture/pr85615.c: New testcase. + 2018-05-03 Kyrylo Tkachov PR tree-optimization/70291 diff --git a/gcc/testsuite/gcc.dg/torture/pr85615.c b/gcc/testsuite/gcc.dg/torture/pr85615.c new file mode 100644 index 00000000000..1695c2e7d1d --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr85615.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ + +long a, d; +int b, c; +void fn1() +{ + int e = -1L, f = 2, g = 8; + for (;;) + { + for (; b; g++) + ; + int i; + for (; c;) + { + i = 5; + for (; e >= 1; i--) + ; + } + d = f ?: a; + if (d) + { + e = 0; + for (; i;) + for (; g < 3; f++) + ; + } + } +} diff --git a/gcc/tree-ssa-threadupdate.c b/gcc/tree-ssa-threadupdate.c index 9ab9e7d7d93..b6bc5fcf175 100644 --- a/gcc/tree-ssa-threadupdate.c +++ b/gcc/tree-ssa-threadupdate.c @@ -1309,7 +1309,9 @@ thread_block_1 (basic_block bb, bool noloop_only, bool joiners) and thread this elsewhere, so just cancel the jump threading request by clearing the AUX field now. */ if (bb->loop_father != e2->src->loop_father - && !loop_exit_edge_p (e2->src->loop_father, e2)) + && (!loop_exit_edge_p (e2->src->loop_father, e2) + || flow_loop_nested_p (bb->loop_father, + e2->dest->loop_father))) { /* Since this case is not handled by our special code to thread through a loop header, we must explicitly -- 2.11.4.GIT