aboutsummaryrefslogtreecommitdiff
path: root/gcc/omp-low.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2012-07-19 14:02:32 +0000
committerJakub Jelinek <jakub@redhat.com>2012-07-19 14:02:32 +0000
commit07f1d2eebe66853d75d3ab5cc9b0776cb69afc03 (patch)
treeb2ceb968dce32746620d8c2755e65d81bba8a568 /gcc/omp-low.c
parent62b4e30ae95d1792679d3b453c9a9254ebc5ac06 (diff)
PR middle-end/54017
* tree-cfgcleanup.c (cleanup_omp_return): Remove. (cleanup_tree_cfg_bb): Don't call it. * omp-low.c (expand_omp_sections): Fix up the !exit_reachable case handling. * c-c++-common/gomp/pr54017.c: New test. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@189658 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/omp-low.c')
-rw-r--r--gcc/omp-low.c83
1 files changed, 37 insertions, 46 deletions
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 8f0932b6c36..03eb399c458 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -4751,45 +4751,40 @@ expand_omp_sections (struct omp_region *region)
unsigned i, casei;
bool exit_reachable = region->cont != NULL;
- gcc_assert (exit_reachable == (region->exit != NULL));
+ gcc_assert (region->exit != NULL);
entry_bb = region->entry;
l0_bb = single_succ (entry_bb);
l1_bb = region->cont;
l2_bb = region->exit;
- if (exit_reachable)
+ if (single_pred_p (l2_bb) && single_pred (l2_bb) == l0_bb)
+ l2 = gimple_block_label (l2_bb);
+ else
{
- if (single_pred_p (l2_bb) && single_pred (l2_bb) == l0_bb)
- l2 = gimple_block_label (l2_bb);
+ /* This can happen if there are reductions. */
+ len = EDGE_COUNT (l0_bb->succs);
+ gcc_assert (len > 0);
+ e = EDGE_SUCC (l0_bb, len - 1);
+ si = gsi_last_bb (e->dest);
+ l2 = NULL_TREE;
+ if (gsi_end_p (si)
+ || gimple_code (gsi_stmt (si)) != GIMPLE_OMP_SECTION)
+ l2 = gimple_block_label (e->dest);
else
- {
- /* This can happen if there are reductions. */
- len = EDGE_COUNT (l0_bb->succs);
- gcc_assert (len > 0);
- e = EDGE_SUCC (l0_bb, len - 1);
- si = gsi_last_bb (e->dest);
- l2 = NULL_TREE;
- if (gsi_end_p (si)
- || gimple_code (gsi_stmt (si)) != GIMPLE_OMP_SECTION)
- l2 = gimple_block_label (e->dest);
- else
- FOR_EACH_EDGE (e, ei, l0_bb->succs)
+ FOR_EACH_EDGE (e, ei, l0_bb->succs)
+ {
+ si = gsi_last_bb (e->dest);
+ if (gsi_end_p (si)
+ || gimple_code (gsi_stmt (si)) != GIMPLE_OMP_SECTION)
{
- si = gsi_last_bb (e->dest);
- if (gsi_end_p (si)
- || gimple_code (gsi_stmt (si)) != GIMPLE_OMP_SECTION)
- {
- l2 = gimple_block_label (e->dest);
- break;
- }
+ l2 = gimple_block_label (e->dest);
+ break;
}
- }
- default_bb = create_empty_bb (l1_bb->prev_bb);
+ }
}
+ if (exit_reachable)
+ default_bb = create_empty_bb (l1_bb->prev_bb);
else
- {
- default_bb = create_empty_bb (l0_bb);
- l2 = gimple_block_label (default_bb);
- }
+ default_bb = create_empty_bb (l0_bb);
/* We will build a switch() with enough cases for all the
GIMPLE_OMP_SECTION regions, a '0' case to handle the end of more work
@@ -4842,13 +4837,9 @@ expand_omp_sections (struct omp_region *region)
vnext = NULL_TREE;
}
- i = 0;
- if (exit_reachable)
- {
- t = build_case_label (build_int_cst (unsigned_type_node, 0), NULL, l2);
- VEC_quick_push (tree, label_vec, t);
- i++;
- }
+ t = build_case_label (build_int_cst (unsigned_type_node, 0), NULL, l2);
+ VEC_quick_push (tree, label_vec, t);
+ i = 1;
/* Convert each GIMPLE_OMP_SECTION into a CASE_LABEL_EXPR. */
for (inner = region->inner, casei = 1;
@@ -4918,18 +4909,18 @@ expand_omp_sections (struct omp_region *region)
gsi_remove (&si, true);
single_succ_edge (l1_bb)->flags = EDGE_FALLTHRU;
-
- /* Cleanup function replaces GIMPLE_OMP_RETURN in EXIT_BB. */
- si = gsi_last_bb (l2_bb);
- if (gimple_omp_return_nowait_p (gsi_stmt (si)))
- t = builtin_decl_explicit (BUILT_IN_GOMP_SECTIONS_END_NOWAIT);
- else
- t = builtin_decl_explicit (BUILT_IN_GOMP_SECTIONS_END);
- stmt = gimple_build_call (t, 0);
- gsi_insert_after (&si, stmt, GSI_SAME_STMT);
- gsi_remove (&si, true);
}
+ /* Cleanup function replaces GIMPLE_OMP_RETURN in EXIT_BB. */
+ si = gsi_last_bb (l2_bb);
+ if (gimple_omp_return_nowait_p (gsi_stmt (si)))
+ t = builtin_decl_explicit (BUILT_IN_GOMP_SECTIONS_END_NOWAIT);
+ else
+ t = builtin_decl_explicit (BUILT_IN_GOMP_SECTIONS_END);
+ stmt = gimple_build_call (t, 0);
+ gsi_insert_after (&si, stmt, GSI_SAME_STMT);
+ gsi_remove (&si, true);
+
set_immediate_dominator (CDI_DOMINATORS, default_bb, l0_bb);
}