aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-loop-ivcanon.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/tree-ssa-loop-ivcanon.c')
-rw-r--r--gcc/tree-ssa-loop-ivcanon.c57
1 files changed, 28 insertions, 29 deletions
diff --git a/gcc/tree-ssa-loop-ivcanon.c b/gcc/tree-ssa-loop-ivcanon.c
index 601223b..108c338 100644
--- a/gcc/tree-ssa-loop-ivcanon.c
+++ b/gcc/tree-ssa-loop-ivcanon.c
@@ -216,7 +216,7 @@ tree_estimate_loop_size (struct loop *loop, edge exit, edge edge_to_cancel, stru
gimple_stmt_iterator gsi;
unsigned int i;
bool after_exit;
- VEC (basic_block, heap) *path = get_loop_hot_path (loop);
+ vec<basic_block> path = get_loop_hot_path (loop);
size->overall = 0;
size->eliminated_by_peeling = 0;
@@ -318,9 +318,9 @@ tree_estimate_loop_size (struct loop *loop, edge exit, edge edge_to_cancel, stru
}
}
}
- while (VEC_length (basic_block, path))
+ while (path.length ())
{
- basic_block bb = VEC_pop (basic_block, path);
+ basic_block bb = path.pop ();
for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
{
gimple stmt = gsi_stmt (gsi);
@@ -350,7 +350,7 @@ tree_estimate_loop_size (struct loop *loop, edge exit, edge edge_to_cancel, stru
size->num_branches_on_hot_path++;
}
}
- VEC_free (basic_block, heap, path);
+ path.release ();
if (dump_file && (dump_flags & TDF_DETAILS))
fprintf (dump_file, "size: %i-%i, last_iteration: %i-%i\n", size->overall,
size->eliminated_by_peeling, size->last_iteration,
@@ -414,7 +414,7 @@ estimated_unrolled_size (struct loop_size *size,
edge
loop_edge_to_cancel (struct loop *loop)
{
- VEC (edge, heap) *exits;
+ vec<edge> exits;
unsigned i;
edge edge_to_cancel;
gimple_stmt_iterator gsi;
@@ -425,7 +425,7 @@ loop_edge_to_cancel (struct loop *loop)
exits = get_loop_exit_edges (loop);
- FOR_EACH_VEC_ELT (edge, exits, i, edge_to_cancel)
+ FOR_EACH_VEC_ELT (exits, i, edge_to_cancel)
{
/* Find the other edge than the loop exit
leaving the conditoinal. */
@@ -447,7 +447,7 @@ loop_edge_to_cancel (struct loop *loop)
if (edge_to_cancel->dest != loop->latch)
continue;
- VEC_free (edge, heap, exits);
+ exits.release ();
/* Verify that the code in loop latch does nothing that may end program
execution without really reaching the exit. This may include
@@ -457,7 +457,7 @@ loop_edge_to_cancel (struct loop *loop)
return NULL;
return edge_to_cancel;
}
- VEC_free (edge, heap, exits);
+ exits.release ();
return NULL;
}
@@ -573,8 +573,8 @@ remove_redundant_iv_tests (struct loop *loop)
}
/* Stores loops that will be unlooped after we process whole loop tree. */
-static VEC(loop_p, heap) *loops_to_unloop;
-static VEC(int, heap) *loops_to_unloop_nunroll;
+static vec<loop_p> loops_to_unloop;
+static vec<int> loops_to_unloop_nunroll;
/* Cancel all fully unrolled loops by putting __builtin_unreachable
on the latch edge.
@@ -592,10 +592,10 @@ void
unloop_loops (bitmap loop_closed_ssa_invalidated,
bool *irred_invalidated)
{
- while (VEC_length (loop_p, loops_to_unloop))
+ while (loops_to_unloop.length ())
{
- struct loop *loop = VEC_pop (loop_p, loops_to_unloop);
- int n_unroll = VEC_pop (int, loops_to_unloop_nunroll);
+ struct loop *loop = loops_to_unloop.pop ();
+ int n_unroll = loops_to_unloop_nunroll.pop ();
basic_block latch = loop->latch;
edge latch_edge = loop_latch_edge (loop);
int flags = latch_edge->flags;
@@ -625,10 +625,8 @@ unloop_loops (bitmap loop_closed_ssa_invalidated,
gsi = gsi_start_bb (latch_edge->dest);
gsi_insert_after (&gsi, stmt, GSI_NEW_STMT);
}
- VEC_free (loop_p, heap, loops_to_unloop);
- loops_to_unloop = NULL;
- VEC_free (int, heap, loops_to_unloop_nunroll);
- loops_to_unloop_nunroll = NULL;
+ loops_to_unloop.release ();
+ loops_to_unloop_nunroll.release ();
}
/* Tries to unroll LOOP completely, i.e. NITER times.
@@ -701,7 +699,7 @@ try_unroll_loop_completely (struct loop *loop,
sbitmap wont_exit;
edge e;
unsigned i;
- VEC (edge, heap) *to_remove = NULL;
+ vec<edge> to_remove = vec<edge>();
if (ul == UL_SINGLE_ITER)
return false;
@@ -817,13 +815,13 @@ try_unroll_loop_completely (struct loop *loop,
return false;
}
- FOR_EACH_VEC_ELT (edge, to_remove, i, e)
+ FOR_EACH_VEC_ELT (to_remove, i, e)
{
bool ok = remove_path (e);
gcc_assert (ok);
}
- VEC_free (edge, heap, to_remove);
+ to_remove.release ();
free (wont_exit);
free_original_copy_tables ();
}
@@ -843,8 +841,8 @@ try_unroll_loop_completely (struct loop *loop,
}
/* Store the loop for later unlooping and exit removal. */
- VEC_safe_push (loop_p, heap, loops_to_unloop, loop);
- VEC_safe_push (int, heap, loops_to_unloop_nunroll, n_unroll);
+ loops_to_unloop.safe_push (loop);
+ loops_to_unloop_nunroll.safe_push (n_unroll);
if (dump_file && (dump_flags & TDF_DETAILS))
{
@@ -1070,7 +1068,7 @@ propagate_constants_for_unrolling (basic_block bb)
unsigned int
tree_unroll_loops_completely (bool may_increase_size, bool unroll_outer)
{
- VEC(loop_p,stack) *father_stack = VEC_alloc (loop_p, stack, 16);
+ vec<loop_p, va_stack> father_stack;
loop_iterator li;
struct loop *loop;
bool changed;
@@ -1078,6 +1076,7 @@ tree_unroll_loops_completely (bool may_increase_size, bool unroll_outer)
int iteration = 0;
bool irred_invalidated = false;
+ vec_stack_alloc (loop_p, father_stack, 16);
do
{
changed = false;
@@ -1111,7 +1110,7 @@ tree_unroll_loops_completely (bool may_increase_size, bool unroll_outer)
iteration is complete and the IR eventually cleaned up. */
if (loop_outer (loop_father) && !loop_father->aux)
{
- VEC_safe_push (loop_p, stack, father_stack, loop_father);
+ father_stack.safe_push (loop_father);
loop_father->aux = loop_father;
}
}
@@ -1124,9 +1123,9 @@ tree_unroll_loops_completely (bool may_increase_size, bool unroll_outer)
/* Be sure to skip unlooped loops while procesing father_stack
array. */
- FOR_EACH_VEC_ELT (loop_p, loops_to_unloop, i, iter)
+ FOR_EACH_VEC_ELT (loops_to_unloop, i, iter)
(*iter)->aux = NULL;
- FOR_EACH_VEC_ELT (loop_p, father_stack, i, iter)
+ FOR_EACH_VEC_ELT (father_stack, i, iter)
if (!(*iter)->aux)
*iter = NULL;
unloop_loops (loop_closed_ssa_invalidated, &irred_invalidated);
@@ -1140,7 +1139,7 @@ tree_unroll_loops_completely (bool may_increase_size, bool unroll_outer)
update_ssa (TODO_update_ssa);
/* Propagate the constants within the new basic blocks. */
- FOR_EACH_VEC_ELT (loop_p, father_stack, i, iter)
+ FOR_EACH_VEC_ELT (father_stack, i, iter)
if (*iter)
{
unsigned j;
@@ -1150,7 +1149,7 @@ tree_unroll_loops_completely (bool may_increase_size, bool unroll_outer)
free (body);
(*iter)->aux = NULL;
}
- VEC_truncate (loop_p, father_stack, 0);
+ father_stack.truncate (0);
/* This will take care of removing completely unrolled loops
from the loop structures so we can continue unrolling now
@@ -1172,7 +1171,7 @@ tree_unroll_loops_completely (bool may_increase_size, bool unroll_outer)
while (changed
&& ++iteration <= PARAM_VALUE (PARAM_MAX_UNROLL_ITERATIONS));
- VEC_free (loop_p, stack, father_stack);
+ father_stack.release ();
if (irred_invalidated
&& loops_state_satisfies_p (LOOPS_HAVE_MARKED_IRREDUCIBLE_REGIONS))