From 307f73ba125cdb239ac62881ab79d6b09ca51aa7 Mon Sep 17 00:00:00 2001 From: rguenth Date: Thu, 8 Mar 2018 14:41:39 +0000 Subject: [PATCH] 2018-03-08 Richard Biener PR middle-end/84552 * tree-scalar-evolution.c: Include tree-into-ssa.h. (follow_copies_to_constant): Do not follow SSA names registered for update. * gcc.dg/graphite/pr84552.c: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@258365 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 7 +++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/graphite/pr84552.c | 23 +++++++++++++++++++++++ gcc/tree-scalar-evolution.c | 6 +++++- 4 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/graphite/pr84552.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index bfff935905f..0d60c551f47 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,12 @@ 2018-03-08 Richard Biener + PR middle-end/84552 + * tree-scalar-evolution.c: Include tree-into-ssa.h. + (follow_copies_to_constant): Do not follow SSA names registered + for update. + +2018-03-08 Richard Biener + PR tree-optimization/84178 * tree-if-conv.c (combine_blocks): Move insert_gimplified_predicates to caller. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3abed3cdbeb..5a5c31a2f6b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,10 @@ 2018-03-08 Richard Biener + PR middle-end/84552 + * gcc.dg/graphite/pr84552.c: New testcase. + +2018-03-08 Richard Biener + PR tree-optimization/84178 * gcc.dg/torture/pr84178-2.c: New testcase. diff --git a/gcc/testsuite/gcc.dg/graphite/pr84552.c b/gcc/testsuite/gcc.dg/graphite/pr84552.c new file mode 100644 index 00000000000..15cbb0848f4 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr84552.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -floop-nest-optimize -fno-tree-copy-prop -fno-tree-fre -fno-tree-loop-ivcanon" } */ + +int cx; + +int +e6 (int pj, int xe) +{ + for (cx = 0; cx < 2; ++cx) + while (xe < 1) + { + for (cx = 0; cx < 2; ++cx) + pj *= 2; + + if (cx != 0) + goto o3; + + ++xe; + } + +o3: + return pj; +} diff --git a/gcc/tree-scalar-evolution.c b/gcc/tree-scalar-evolution.c index 0ba1aa8359a..fefc9de96af 100644 --- a/gcc/tree-scalar-evolution.c +++ b/gcc/tree-scalar-evolution.c @@ -280,6 +280,7 @@ along with GCC; see the file COPYING3. If not see #include "params.h" #include "tree-ssa-propagate.h" #include "gimple-fold.h" +#include "tree-into-ssa.h" static tree analyze_scalar_evolution_1 (struct loop *, tree); static tree analyze_scalar_evolution_for_address_of (struct loop *loop, @@ -1540,7 +1541,10 @@ static tree follow_copies_to_constant (tree var) { tree res = var; - while (TREE_CODE (res) == SSA_NAME) + while (TREE_CODE (res) == SSA_NAME + /* We face not updated SSA form in multiple places and this walk + may end up in sibling loops so we have to guard it. */ + && !name_registered_for_update_p (res)) { gimple *def = SSA_NAME_DEF_STMT (res); if (gphi *phi = dyn_cast (def)) -- 2.11.4.GIT