diff options
Diffstat (limited to 'gcc/cfgloopmanip.c')
-rw-r--r-- | gcc/cfgloopmanip.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/gcc/cfgloopmanip.c b/gcc/cfgloopmanip.c index 83d4e4c0e13..9021fbafd4e 100644 --- a/gcc/cfgloopmanip.c +++ b/gcc/cfgloopmanip.c @@ -814,11 +814,12 @@ update_single_exit_for_duplicated_loops (struct loop *orig_loops[], unsigned n) original LOOP body, the other copies are numbered in order given by control flow through them) into TO_REMOVE array. Returns false if duplication is impossible. */ + bool duplicate_loop_to_header_edge (struct loop *loop, edge e, unsigned int ndupl, sbitmap wont_exit, - edge orig, edge *to_remove, - unsigned int *n_to_remove, int flags) + edge orig, VEC (edge, heap) **to_remove, + int flags) { struct loop *target, *aloop; struct loop **orig_loops; @@ -966,10 +967,6 @@ duplicate_loop_to_header_edge (struct loop *loop, edge e, if (current_loops->state & LOOPS_HAVE_MARKED_SINGLE_EXITS) update_single_exits_after_duplication (bbs, n, target); - /* Record exit edge in original loop body. */ - if (orig && TEST_BIT (wont_exit, 0)) - to_remove[(*n_to_remove)++] = orig; - spec_edges[SE_ORIG] = orig; spec_edges[SE_LATCH] = latch_edge; @@ -1043,7 +1040,10 @@ duplicate_loop_to_header_edge (struct loop *loop, edge e, /* Record exit edge in this copy. */ if (orig && TEST_BIT (wont_exit, j + 1)) - to_remove[(*n_to_remove)++] = new_spec_edges[SE_ORIG]; + { + if (to_remove) + VEC_safe_push (edge, heap, *to_remove, new_spec_edges[SE_ORIG]); + } /* Record the first copy in the control flow order if it is not the original loop (i.e. in case of peeling). */ @@ -1063,6 +1063,13 @@ duplicate_loop_to_header_edge (struct loop *loop, edge e, free (new_bbs); free (orig_loops); + /* Record the exit edge in the original loop body, and update the frequencies. */ + if (orig && TEST_BIT (wont_exit, 0)) + { + if (to_remove) + VEC_safe_push (edge, heap, *to_remove, orig); + } + /* Update the original loop. */ if (!is_latch) set_immediate_dominator (CDI_DOMINATORS, e->dest, e->src); @@ -1302,7 +1309,7 @@ loop_version (struct loop *loop, /* Duplicate loop. */ if (!cfg_hook_duplicate_loop_to_header_edge (loop, entry, 1, - NULL, NULL, NULL, NULL, 0)) + NULL, NULL, NULL, 0)) return NULL; /* After duplication entry edge now points to new loop head block. |