From 7bcba067fbc02490829567b87b878bf92a42a047 Mon Sep 17 00:00:00 2001 From: jakub Date: Sat, 11 Apr 2015 17:32:54 +0000 Subject: [PATCH] PR tree-optimization/65735 * tree-ssa-threadedge.c (fsm_find_control_statement_thread_paths): Remove visited_phis argument, add visited_bbs, avoid recursing into the same bb rather than just into the same phi node. (thread_through_normal_block): Adjust caller. * gcc.c-torture/compile/pr65735.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@222011 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 8 ++++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.c-torture/compile/pr65735.c | 21 +++++++++++++++++++++ gcc/tree-ssa-threadedge.c | 12 ++++++------ 4 files changed, 40 insertions(+), 6 deletions(-) create mode 100644 gcc/testsuite/gcc.c-torture/compile/pr65735.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d001031..ce59ef8 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2015-04-11 Jakub Jelinek + + PR tree-optimization/65735 + * tree-ssa-threadedge.c (fsm_find_control_statement_thread_paths): + Remove visited_phis argument, add visited_bbs, avoid recursing into the + same bb rather than just into the same phi node. + (thread_through_normal_block): Adjust caller. + 2015-04-11 Gerald Pfeifer * doc/contrib.texi (Contributors): Add Ira Rosen. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 1d72497..75c3b44 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-04-11 Jakub Jelinek + + PR tree-optimization/65735 + * gcc.c-torture/compile/pr65735.c: New test. + 2015-04-11 H.J. Lu PR middle-end/65554 diff --git a/gcc/testsuite/gcc.c-torture/compile/pr65735.c b/gcc/testsuite/gcc.c-torture/compile/pr65735.c new file mode 100644 index 0000000..c30de8e --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr65735.c @@ -0,0 +1,21 @@ +/* PR tree-optimization/65735 */ + +int foo (void); + +void +bar (int a, int b, int c) +{ + while (!a) + { + c = foo (); + if (c == 7) + c = b; + switch (c) + { + case 1: + a = b++; + if (b) + b = 1; + } + } +} diff --git a/gcc/tree-ssa-threadedge.c b/gcc/tree-ssa-threadedge.c index 7187d06..90c1e2a 100644 --- a/gcc/tree-ssa-threadedge.c +++ b/gcc/tree-ssa-threadedge.c @@ -1015,7 +1015,7 @@ static int max_threaded_paths; static void fsm_find_control_statement_thread_paths (tree expr, - hash_set *visited_phis, + hash_set *visited_bbs, vec *&path, bool seen_loop_phi) { @@ -1034,7 +1034,7 @@ fsm_find_control_statement_thread_paths (tree expr, return; /* Avoid infinite recursion. */ - if (visited_phis->add (def_stmt)) + if (visited_bbs->add (var_bb)) return; gphi *phi = as_a (def_stmt); @@ -1109,7 +1109,7 @@ fsm_find_control_statement_thread_paths (tree expr, { vec_safe_push (path, bbi); /* Recursively follow SSA_NAMEs looking for a constant definition. */ - fsm_find_control_statement_thread_paths (arg, visited_phis, path, + fsm_find_control_statement_thread_paths (arg, visited_bbs, path, seen_loop_phi); path->pop (); @@ -1391,13 +1391,13 @@ thread_through_normal_block (edge e, vec *bb_path; vec_alloc (bb_path, n_basic_blocks_for_fn (cfun)); vec_safe_push (bb_path, e->dest); - hash_set *visited_phis = new hash_set; + hash_set *visited_bbs = new hash_set; max_threaded_paths = PARAM_VALUE (PARAM_MAX_FSM_THREAD_PATHS); - fsm_find_control_statement_thread_paths (cond, visited_phis, bb_path, + fsm_find_control_statement_thread_paths (cond, visited_bbs, bb_path, false); - delete visited_phis; + delete visited_bbs; vec_free (bb_path); } return 0; -- 2.7.4