[PATCH] [PR tree-optimization/68013] Make sure first block in FSM path
authorJeff Law <law@redhat.com>
Mon, 26 Oct 2015 15:36:04 +0000 (09:36 -0600)
committerJeff Law <law@gcc.gnu.org>
Mon, 26 Oct 2015 15:36:04 +0000 (09:36 -0600)
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
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr68013.c [new file with mode: 0644]
gcc/tree-ssa-threadbackward.c

index 95479f3793a46318e32962ca0f925d98712133e4..b5cfa1e693fc81f8b98bf7261fce7c0f2b4fac71 100644 (file)
@@ -1,3 +1,10 @@
+2015-10-26  Jeff Law  <law@redhat.com>
+
+       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  <rguenther@suse.de>
        Dominik Vogt  <vogt@linux.vnet.ibm.com>
 
index fd5ade4ac889d2dda906638221dc3c308530d57d..688f7456fe84863eec250bfbda75208e71a7bc91 100644 (file)
@@ -1,3 +1,8 @@
+2015-10-26  Jeff Law  <law@redhat.com>
+
+       PR tree-optimization/68013
+       * gcc.c-torture/compile/pr68013.c: New test.
+
 2015-10-26  Richard Biener  <rguenther@suse.de>
        Dominik Vogt  <vogt@linux.vnet.ibm.com>
 
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr68013.c b/gcc/testsuite/gcc.c-torture/compile/pr68013.c
new file mode 100644 (file)
index 0000000..cc500da
--- /dev/null
@@ -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;
+    }
+}
index 91280947ec320ca267f5db58343be7959a0da8bd..cfb4ace8e9dfbd9c0d10fbcffe20c0d1e1049785 100644 (file)
@@ -136,6 +136,11 @@ fsm_find_control_statement_thread_paths (tree name,
       vec<basic_block, va_gc> *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<basic_block> *visited_bbs = new hash_set<basic_block>;