Re: [PATCH] Improve DOM's optimization of control statements
authorJeff Law <law@redhat.com>
Wed, 7 Oct 2015 21:56:18 +0000 (15:56 -0600)
committerJeff Law <law@gcc.gnu.org>
Wed, 7 Oct 2015 21:56:18 +0000 (15:56 -0600)
* tree-ssa-dom.c (optimize_stmt): Don't set LOOPS_NEED_FIXUP here.
* tree-ssa-threadupdate.c (remove_ctrl_stmt_and_useless_edges): Do it
here instead.  Tighten test to avoid setting LOOPS_NEED_FIXUP
unnecessarily.

@@ -1848,12 +1848,6 @@ optimize_stmt (basic_block bb, gimple_stmt_iterator si,

From-SVN: r228585

gcc/ChangeLog
gcc/tree-ssa-dom.c
gcc/tree-ssa-threadupdate.c

index e2aad2295fa1129f5467ee4dad9635bf6b81e293..86be03e54770bd54eea2a160b7f7406ba1231aaf 100644 (file)
@@ -1,3 +1,11 @@
+2015-10-07  Jeff Law  <law@redhat.com>
+
+       * tree-ssa-dom.c (optimize_stmt): Don't set LOOPS_NEED_FIXUP here.
+       * tree-ssa-threadupdate.c (remove_ctrl_stmt_and_useless_edges): Do it
+       here instead.  Tighten test to avoid setting LOOPS_NEED_FIXUP 
+       unnecessarily.
+
+@@ -1848,12 +1848,6 @@ optimize_stmt (basic_block bb, gimple_stmt_iterator si,
 2015-10-07  Aditya Kumar  <aditya.k7@samsung.com>
            Sebastian Pop  <s.pop@samsung.com>
 
index 941087d56ded13f8bbdbc5b2d16d9b8e50a0f89d..38cceff2c84a90ffd98bfa076e74c9aa10109f3f 100644 (file)
@@ -1848,12 +1848,6 @@ optimize_stmt (basic_block bb, gimple_stmt_iterator si,
              FOR_EACH_EDGE (e, ei, bb->succs)
                remove_jump_threads_including (e);
 
-             /* If BB is in a loop, then removing an outgoing edge from BB
-                may cause BB to move outside the loop, changes in the
-                loop exit edges, etc.  So note that loops need fixing.  */
-             if (bb_loop_depth (bb) > 0)
-               loops_state_set (LOOPS_NEED_FIXUP);
-
              /* Now clean up the control statement at the end of
                 BB and remove unexecutable edges.  */
              remove_ctrl_stmt_and_useless_edges (bb, taken_edge->dest);
index 26b199b2c79f5d78c425c53833c0a88d5f1c03d4..e426c1db9e9ee8e170cd0ee45081c564ba91d40b 100644 (file)
@@ -300,6 +300,17 @@ remove_ctrl_stmt_and_useless_edges (basic_block bb, basic_block dest_bb)
       else
        ei_next (&ei);
     }
+
+  /* If the remaining edge is a loop exit, there must have
+     a removed edge that was not a loop exit.
+
+     In that case BB and possibly other blocks were previously
+     in the loop, but are now outside the loop.  Thus, we need
+     to update the loop structures.  */
+  if (single_succ_p (bb)
+      && loop_outer (bb->loop_father)
+      && loop_exit_edge_p (bb->loop_father, single_succ_edge (bb)))
+    loops_state_set (LOOPS_NEED_FIXUP);
 }
 
 /* Create a duplicate of BB.  Record the duplicate block in an array