From 69958396d92cc0b3948572e8b2348c30ef22e0a5 Mon Sep 17 00:00:00 2001 From: Razya Ladelsky Date: Sun, 22 Apr 2012 10:36:13 +0000 Subject: Correcting transform_to_exit_first_loop + fix to PR tree-optimization/46886 2012-04-20 Razya Ladelsky Correcting transform_to_exit_first_loop + fix to PR tree-optimization/46886 * tree-parloops.c (transform_to_exit_first_loop): * Remove setting of number of iterations according to * the loop pattern. Duplicate from entry to exit->src instead of loop->latch. (pallelize_loops): Remove the condition preventing do-while loops. * tree-cfg.c (bool bb_in_region_p): New. (gimple_duplicate_sese_tail): Adjust duplication of the the subloops. Adjust redirection of the duplicated iteration. From-SVN: r186667 --- gcc/tree-cfg.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'gcc/tree-cfg.c') diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index 7245566..e32daa7 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -5595,6 +5595,20 @@ gimple_duplicate_sese_region (edge entry, edge exit, return true; } +/* Checks if BB is part of the region defined by N_REGION BBS. */ +static bool +bb_part_of_region_p (basic_block bb, basic_block* bbs, unsigned n_region) +{ + unsigned int n; + + for (n = 0; n < n_region; n++) + { + if (bb == bbs[n]) + return true; + } + return false; +} + /* Duplicates REGION consisting of N_REGION blocks. The new blocks are stored to REGION_COPY in the same order in that they appear in REGION, if REGION_COPY is not NULL. ENTRY is the entry to @@ -5645,6 +5659,7 @@ gimple_duplicate_sese_tail (edge entry ATTRIBUTE_UNUSED, edge exit ATTRIBUTE_UNU gimple_stmt_iterator psi; gimple phi; tree def; + struct loop *target, *aloop, *cloop; gcc_assert (EDGE_COUNT (exit->src->succs) == 2); exits[0] = exit; @@ -5655,7 +5670,16 @@ gimple_duplicate_sese_tail (edge entry ATTRIBUTE_UNUSED, edge exit ATTRIBUTE_UNU initialize_original_copy_tables (); set_loop_copy (orig_loop, loop); - duplicate_subloops (orig_loop, loop); + + target= loop; + for (aloop = orig_loop->inner; aloop; aloop = aloop->next) + { + if (bb_part_of_region_p (aloop->header, region, n_region)) + { + cloop = duplicate_loop (aloop, target); + duplicate_subloops (aloop, cloop); + } + } if (!region_copy) { @@ -5758,7 +5782,7 @@ gimple_duplicate_sese_tail (edge entry ATTRIBUTE_UNUSED, edge exit ATTRIBUTE_UNU add_phi_arg (phi, def, e, gimple_phi_arg_location_from_edge (phi, e)); } } - e = redirect_edge_and_branch (nexits[0], nexits[1]->dest); + e = redirect_edge_and_branch (nexits[1], nexits[0]->dest); PENDING_STMT (e) = NULL; /* Anything that is outside of the region, but was dominated by something -- cgit v1.1