diff options
author | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-09-27 13:44:10 +0000 |
---|---|---|
committer | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-09-27 13:44:10 +0000 |
commit | fc33577d2d1e4a8adcf9df53d869fdad1cd49d84 (patch) | |
tree | 397b9bfaf3b6c235b4e2f991fd202f64d3ef1996 /gcc/tree-cfg.c | |
parent | 2de52d0943f1289663e9190a0108b799e0e82976 (diff) | |
download | gcc-fc33577d2d1e4a8adcf9df53d869fdad1cd49d84.tar.gz |
PR middle-end/58551
* tree-cfg.c (move_sese_region_to_fn): Also move loops that
are children of outermost saved_cfun's loop, and set it up to
be moved to dest_cfun's outermost loop. Fix up num_nodes adjustments
if loop != loop0 and SESE region contains bbs that belong to loop0.
* c-c++-common/gomp/pr58551.c: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@202972 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-cfg.c')
-rw-r--r-- | gcc/tree-cfg.c | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index 70930a3592a..d1a6c31c27d 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -6662,12 +6662,13 @@ move_sese_region_to_fn (struct function *dest_cfun, basic_block entry_bb, struct function *saved_cfun = cfun; int *entry_flag, *exit_flag; unsigned *entry_prob, *exit_prob; - unsigned i, num_entry_edges, num_exit_edges; + unsigned i, num_entry_edges, num_exit_edges, num_nodes; edge e; edge_iterator ei; htab_t new_label_map; struct pointer_map_t *vars_map, *eh_map; struct loop *loop = entry_bb->loop_father; + struct loop *loop0 = get_loop (saved_cfun, 0); struct move_stmt_d d; /* If ENTRY does not strictly dominate EXIT, this cannot be an SESE @@ -6760,16 +6761,29 @@ move_sese_region_to_fn (struct function *dest_cfun, basic_block entry_bb, set_loops_for_fn (dest_cfun, loops); /* Move the outlined loop tree part. */ + num_nodes = bbs.length (); FOR_EACH_VEC_ELT (bbs, i, bb) { - if (bb->loop_father->header == bb - && loop_outer (bb->loop_father) == loop) + if (bb->loop_father->header == bb) { struct loop *this_loop = bb->loop_father; - flow_loop_tree_node_remove (bb->loop_father); - flow_loop_tree_node_add (get_loop (dest_cfun, 0), this_loop); - fixup_loop_arrays_after_move (saved_cfun, cfun, this_loop); + struct loop *outer = loop_outer (this_loop); + if (outer == loop + /* If the SESE region contains some bbs ending with + a noreturn call, those are considered to belong + to the outermost loop in saved_cfun, rather than + the entry_bb's loop_father. */ + || outer == loop0) + { + if (outer != loop) + num_nodes -= this_loop->num_nodes; + flow_loop_tree_node_remove (bb->loop_father); + flow_loop_tree_node_add (get_loop (dest_cfun, 0), this_loop); + fixup_loop_arrays_after_move (saved_cfun, cfun, this_loop); + } } + else if (bb->loop_father == loop0 && loop0 != loop) + num_nodes--; /* Remove loop exits from the outlined region. */ if (loops_for_fn (saved_cfun)->exits) @@ -6789,6 +6803,7 @@ move_sese_region_to_fn (struct function *dest_cfun, basic_block entry_bb, /* Setup a mapping to be used by move_block_to_fn. */ loop->aux = current_loops->tree_root; + loop0->aux = current_loops->tree_root; pop_cfun (); @@ -6817,11 +6832,13 @@ move_sese_region_to_fn (struct function *dest_cfun, basic_block entry_bb, } loop->aux = NULL; + loop0->aux = NULL; /* Loop sizes are no longer correct, fix them up. */ - loop->num_nodes -= bbs.length (); + loop->num_nodes -= num_nodes; for (struct loop *outer = loop_outer (loop); outer; outer = loop_outer (outer)) - outer->num_nodes -= bbs.length (); + outer->num_nodes -= num_nodes; + loop0->num_nodes -= bbs.length () - num_nodes; if (saved_cfun->has_simduid_loops || saved_cfun->has_force_vect_loops) { |