From 08c13199cf5568393fd46481d99cf1729480548a Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Fri, 5 Sep 2014 09:17:49 +0000 Subject: [PATCH] cfgloop.c (mark_loop_for_removal): New function. 2014-09-05 Richard Biener * cfgloop.c (mark_loop_for_removal): New function. * cfgloop.h (mark_loop_for_removal): Declare. * cfghooks.c (delete_basic_block): Use mark_loop_for_removal. (merge_blocks): Likewise. (duplicate_block): Likewise. * except.c (sjlj_emit_dispatch_table): Likewise. * tree-eh.c (cleanup_empty_eh_merge_phis): Likewise. * tree-ssa-threadupdate.c (ssa_redirect_edges): Likewise. (thread_through_loop_header): Likewise. From-SVN: r214942 --- gcc/ChangeLog | 12 ++++++++++++ gcc/cfghooks.c | 18 ++++-------------- gcc/cfgloop.c | 10 ++++++++++ gcc/cfgloop.h | 2 ++ gcc/except.c | 5 +---- gcc/tree-eh.c | 5 ++--- gcc/tree-ssa-threadupdate.c | 10 ++-------- 7 files changed, 33 insertions(+), 29 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 51c8a08df69..9c329a9189e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,15 @@ +2014-09-05 Richard Biener + + * cfgloop.c (mark_loop_for_removal): New function. + * cfgloop.h (mark_loop_for_removal): Declare. + * cfghooks.c (delete_basic_block): Use mark_loop_for_removal. + (merge_blocks): Likewise. + (duplicate_block): Likewise. + * except.c (sjlj_emit_dispatch_table): Likewise. + * tree-eh.c (cleanup_empty_eh_merge_phis): Likewise. + * tree-ssa-threadupdate.c (ssa_redirect_edges): Likewise. + (thread_through_loop_header): Likewise. + 2014-09-05 Richard Biener PR middle-end/63148 diff --git a/gcc/cfghooks.c b/gcc/cfghooks.c index 90bc6cf1e9f..fa18214e1ff 100644 --- a/gcc/cfghooks.c +++ b/gcc/cfghooks.c @@ -569,14 +569,10 @@ delete_basic_block (basic_block bb) struct loop *loop = bb->loop_father; /* If we remove the header or the latch of a loop, mark the loop for - removal by setting its header and latch to NULL. */ + removal. */ if (loop->latch == bb || loop->header == bb) - { - loop->header = NULL; - loop->latch = NULL; - loops_state_set (LOOPS_NEED_FIXUP); - } + mark_loop_for_removal (loop); remove_bb_from_loops (bb); } @@ -760,11 +756,7 @@ merge_blocks (basic_block a, basic_block b) /* ... we merge two loop headers, in which case we kill the inner loop. */ if (b->loop_father->header == b) - { - b->loop_father->header = NULL; - b->loop_father->latch = NULL; - loops_state_set (LOOPS_NEED_FIXUP); - } + mark_loop_for_removal (b->loop_father); } /* If we merge a loop header into its predecessor, update the loop structure. */ @@ -1099,9 +1091,7 @@ duplicate_block (basic_block bb, edge e, basic_block after) && cloop->header == bb) { add_bb_to_loop (new_bb, loop_outer (cloop)); - cloop->header = NULL; - cloop->latch = NULL; - loops_state_set (LOOPS_NEED_FIXUP); + mark_loop_for_removal (cloop); } else { diff --git a/gcc/cfgloop.c b/gcc/cfgloop.c index dcf23ca1fbb..789c45a8f03 100644 --- a/gcc/cfgloop.c +++ b/gcc/cfgloop.c @@ -1921,3 +1921,13 @@ bb_loop_depth (const_basic_block bb) { return bb->loop_father ? loop_depth (bb->loop_father) : 0; } + +/* Marks LOOP for removal and sets LOOPS_NEED_FIXUP. */ + +void +mark_loop_for_removal (loop_p loop) +{ + loop->header = NULL; + loop->latch = NULL; + loops_state_set (LOOPS_NEED_FIXUP); +} diff --git a/gcc/cfgloop.h b/gcc/cfgloop.h index b7f5d2a22a6..e868f5d4ba1 100644 --- a/gcc/cfgloop.h +++ b/gcc/cfgloop.h @@ -336,6 +336,8 @@ struct loop * loop_version (struct loop *, void *, extern bool remove_path (edge); extern void unloop (struct loop *, bool *, bitmap); extern void scale_loop_frequencies (struct loop *, int, int); +void mark_loop_for_removal (loop_p); + /* Induction variable analysis. */ diff --git a/gcc/except.c b/gcc/except.c index fecc06046a2..78518ea808b 100644 --- a/gcc/except.c +++ b/gcc/except.c @@ -1375,10 +1375,7 @@ sjlj_emit_dispatch_table (rtx_code_label *dispatch_label, int num_dispatch) { for (loop = bb->loop_father; loop_outer (loop); loop = loop_outer (loop)) - { - loop->header = NULL; - loop->latch = NULL; - } + mark_loop_for_removal (loop); } } diff --git a/gcc/tree-eh.c b/gcc/tree-eh.c index 9da8da28b36..d8032538c0a 100644 --- a/gcc/tree-eh.c +++ b/gcc/tree-eh.c @@ -4171,10 +4171,9 @@ cleanup_empty_eh_merge_phis (basic_block new_bb, basic_block old_bb, and mark the other loop as possibly having multiple latches. */ if (e->dest == e->dest->loop_father->header) { - e->dest->loop_father->header = NULL; - e->dest->loop_father->latch = NULL; + mark_loop_for_removal (e->dest->loop_father); new_bb->loop_father->latch = NULL; - loops_state_set (LOOPS_NEED_FIXUP|LOOPS_MAY_HAVE_MULTIPLE_LATCHES); + loops_state_set (LOOPS_MAY_HAVE_MULTIPLE_LATCHES); } redirect_eh_edge_1 (e, new_bb, change_region); redirect_edge_succ (e, new_bb); diff --git a/gcc/tree-ssa-threadupdate.c b/gcc/tree-ssa-threadupdate.c index a0b1be544ad..ae1e7bacb5a 100644 --- a/gcc/tree-ssa-threadupdate.c +++ b/gcc/tree-ssa-threadupdate.c @@ -766,11 +766,7 @@ ssa_redirect_edges (struct redirection_data **slot, /* If we redirect a loop latch edge cancel its loop. */ if (e->src == e->src->loop_father->latch) - { - e->src->loop_father->header = NULL; - e->src->loop_father->latch = NULL; - loops_state_set (LOOPS_NEED_FIXUP); - } + mark_loop_for_removal (e->src->loop_father); /* Redirect the incoming edge (possibly to the joiner block) to the appropriate duplicate block. */ @@ -1304,9 +1300,7 @@ thread_through_loop_header (struct loop *loop, bool may_peel_loop_headers) { /* If the loop ceased to exist, mark it as such, and thread through its original header. */ - loop->header = NULL; - loop->latch = NULL; - loops_state_set (LOOPS_NEED_FIXUP); + mark_loop_for_removal (loop); return thread_block (header, false); } -- 2.30.2