From c67e5194634c5c3dfd16580e862fb9d4a4552bc9 Mon Sep 17 00:00:00 2001 From: Jeff Law Date: Mon, 26 Oct 2015 09:36:04 -0600 Subject: [PATCH] [PATCH] [PR tree-optimization/68013] Make sure first block in FSM path is in VISITED_BBs PR tree-optimization/68013 * tree-ssa-threadbackward.c (fsm_find_control_statement_thread_paths): Make sure the first block in the path is in VISITED_BBs. PR tree-optimization/68013 * gcc.c-torture/compile/pr68013.c: New test. From-SVN: r229375 --- gcc/ChangeLog | 7 +++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.c-torture/compile/pr68013.c | 16 ++++++++++++++++ gcc/tree-ssa-threadbackward.c | 5 +++++ 4 files changed, 33 insertions(+) create mode 100644 gcc/testsuite/gcc.c-torture/compile/pr68013.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 95479f3793a..b5cfa1e693f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2015-10-26 Jeff Law + + PR tree-optimization/68013 + * tree-ssa-threadbackward.c + (fsm_find_control_statement_thread_paths): Make sure the first block + in the path is in VISITED_BBs. + 2015-10-26 Richard Biener Dominik Vogt diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index fd5ade4ac88..688f7456fe8 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-10-26 Jeff Law + + PR tree-optimization/68013 + * gcc.c-torture/compile/pr68013.c: New test. + 2015-10-26 Richard Biener Dominik Vogt diff --git a/gcc/testsuite/gcc.c-torture/compile/pr68013.c b/gcc/testsuite/gcc.c-torture/compile/pr68013.c new file mode 100644 index 00000000000..cc500da421e --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr68013.c @@ -0,0 +1,16 @@ +int a, b, c, d, e, f; + +void +fn1 () +{ + for (; e;) + { + e = f; + for (; b;) + { + b = a; + f = a || d ? 0 : c; + } + d = 0; + } +} diff --git a/gcc/tree-ssa-threadbackward.c b/gcc/tree-ssa-threadbackward.c index 91280947ec3..cfb4ace8e9d 100644 --- a/gcc/tree-ssa-threadbackward.c +++ b/gcc/tree-ssa-threadbackward.c @@ -136,6 +136,11 @@ fsm_find_control_statement_thread_paths (tree name, vec *next_path; vec_alloc (next_path, n_basic_blocks_for_fn (cfun)); + /* When VAR_BB == LAST_BB_IN_PATH, then the first block in the path + will already be in VISITED_BBS. When they are not equal, then we + must ensure that first block is accounted for to ensure we do not + create bogus jump threading paths. */ + visited_bbs->add ((*path)[0]); FOR_EACH_EDGE (e, ei, last_bb_in_path->preds) { hash_set *visited_bbs = new hash_set; -- 2.30.2