/* Returns the list of the exit edges of a LOOP. */
-vec<edge>
+auto_vec<edge>
get_loop_exit_edges (const class loop *loop, basic_block *body)
{
- vec<edge> edges = vNULL;
+ auto_vec<edge> edges;
edge e;
unsigned i;
edge_iterator ei;
extern basic_block *get_loop_body_in_custom_order (const class loop *, void *,
int (*) (const void *, const void *, void *));
-extern vec<edge> get_loop_exit_edges (const class loop *, basic_block * = NULL);
+extern auto_vec<edge> get_loop_exit_edges (const class loop *, basic_block * = NULL);
extern edge single_exit (const class loop *);
extern edge single_likely_exit (class loop *loop, vec<edge>);
extern unsigned num_loop_branches (const class loop *);
{
unsigned i;
edge e;
- vec<edge> exits = get_loop_exit_edges (loop);
+ auto_vec<edge> exits = get_loop_exit_edges (loop);
class loop *father = current_loops->tree_root, *act;
bool ret = false;
ret = true;
}
- exits.release ();
return ret;
}
if (!is_empty (x) && !is_deleted (x))
{
value_type *q = find_empty_slot_for_expand (Descriptor::hash (x));
- new ((void*) q) value_type (x);
+ new ((void*) q) value_type (std::move (x));
}
p++;
scev_initialize ();
FOR_EACH_LOOP (loop, 0)
{
- vec<edge> exits;
edge ex;
unsigned int j;
class tree_niter_desc niter_desc;
else
bb_predicate = false;
- exits = get_loop_exit_edges (loop);
+ auto_vec<edge> exits = get_loop_exit_edges (loop);
FOR_EACH_VEC_ELT (exits, j, ex)
if (number_of_iterations_exit (loop, ex, &niter_desc, false)
&& !is_gimple_min_invariant (niter_desc.niter))
loop with independent predicate. */
loop_iterations &= will_be_nonconstant;
}
- exits.release ();
}
/* To avoid quadratic behavior we analyze stride predicates only
bool skip_p;
edge_iterator ei;
edge e;
- vec<edge> edges;
loop_p loop;
ira_bb_nodes
}
if (skip_p)
continue;
- edges = get_loop_exit_edges (loop);
+ auto_vec<edge> edges = get_loop_exit_edges (loop);
FOR_EACH_VEC_ELT (edges, j, e)
if ((e->flags & EDGE_ABNORMAL) && EDGE_CRITICAL_P (e))
{
skip_p = true;
break;
}
- edges.release ();
if (skip_p)
continue;
}
int i;
edge_iterator ei;
edge e;
- vec<edge> edges;
ira_assert (current_loops != NULL);
FOR_EACH_EDGE (e, ei, loop_node->loop->header->preds)
if (e->src != loop_node->loop->latch)
create_loop_allocnos (e);
- edges = get_loop_exit_edges (loop_node->loop);
+ auto_vec<edge> edges = get_loop_exit_edges (loop_node->loop);
FOR_EACH_VEC_ELT (edges, i, e)
create_loop_allocnos (e);
- edges.release ();
}
}
int i;
edge_iterator ei;
edge e;
- vec<edge> edges;
bool res;
FOR_EACH_EDGE (e, ei, loop->header->preds)
if (e->flags & EDGE_EH)
return true;
- edges = get_loop_exit_edges (loop);
+ auto_vec<edge> edges = get_loop_exit_edges (loop);
res = false;
FOR_EACH_VEC_ELT (edges, i, e)
if (e->flags & EDGE_COMPLEX)
res = true;
break;
}
- edges.release ();
return res;
}
#endif
int freq, i;
edge_iterator ei;
edge e;
- vec<edge> edges;
ira_assert (current_loops != NULL && loop_node->loop != NULL
&& (regno < 0 || regno >= FIRST_PSEUDO_REGISTER));
}
else
{
- edges = get_loop_exit_edges (loop_node->loop);
+ auto_vec<edge> edges = get_loop_exit_edges (loop_node->loop);
FOR_EACH_VEC_ELT (edges, i, e)
if (regno < 0
|| (bitmap_bit_p (df_get_live_out (e->src), regno)
&& bitmap_bit_p (df_get_live_in (e->dest), regno)))
freq += EDGE_FREQUENCY (e);
- edges.release ();
}
return REG_FREQ_FROM_EDGE_FREQ (freq);
struct var_to_expand *ves = NULL;
iv_to_split **slot1;
var_to_expand **slot2;
- vec<edge> edges = get_loop_exit_edges (loop);
+ auto_vec<edge> edges = get_loop_exit_edges (loop);
edge exit;
bool can_apply = false;
}
}
- edges.release ();
free (body);
return opt_info;
}
{
basic_block bb, *bbs;
unsigned j, n_exits = 0;
- vec<edge> exits;
class tree_niter_desc niter_desc;
edge ex;
class nb_iter_bound *nb_iter;
gcond *stmt = NULL;
bool recursion = with_recursion.contains (loop);
- exits = get_loop_exit_edges (loop);
+ auto_vec<edge> exits = get_loop_exit_edges (loop);
FOR_EACH_VEC_ELT (exits, j, ex)
if (!unlikely_executed_edge_p (ex) && !(ex->flags & EDGE_ABNORMAL_CALL))
n_exits ++;
if (!n_exits)
- {
- exits.release ();
- continue;
- }
+ continue;
if (dump_file && (dump_flags & TDF_DETAILS))
fprintf (dump_file, "Predicting loop %i%s with %i exits.\n",
probability = RDIV (REG_BR_PROB_BASE, nitercst);
predict_edge (ex, predictor, probability);
}
- exits.release ();
/* Find information about loop bound variables. */
for (nb_iter = loop->bounds; nb_iter;
last_always_executed_block (class loop *loop)
{
unsigned i;
- vec<edge> exits = get_loop_exit_edges (loop);
+ auto_vec<edge> exits = get_loop_exit_edges (loop);
edge ex;
basic_block last = loop->latch;
FOR_EACH_VEC_ELT (exits, i, ex)
last = nearest_common_dominator (CDI_DOMINATORS, last, ex->src);
- exits.release ();
return last;
}
{
edge entry = copied[i].first;
loop_p loop = copied[i].second;
- vec<edge> exit_edges = get_loop_exit_edges (loop);
+ auto_vec<edge> exit_edges = get_loop_exit_edges (loop);
bitmap exit_bbs = BITMAP_ALLOC (NULL);
for (unsigned j = 0; j < exit_edges.length (); ++j)
bitmap_set_bit (exit_bbs, exit_edges[j]->dest->index);
bitmap_set_bit (exit_bbs, loop->header->index);
do_rpo_vn (cfun, entry, exit_bbs);
BITMAP_FREE (exit_bbs);
- exit_edges.release ();
}
}
free (bbs);
static void
store_motion_loop (class loop *loop, bitmap sm_executed)
{
- vec<edge> exits = get_loop_exit_edges (loop);
+ auto_vec<edge> exits = get_loop_exit_edges (loop);
class loop *subloop;
bitmap sm_in_loop = BITMAP_ALLOC (&lim_bitmap_obstack);
if (!bitmap_empty_p (sm_in_loop))
hoist_memory_references (loop, sm_in_loop, exits);
}
- exits.release ();
bitmap_ior_into (sm_executed, sm_in_loop);
for (subloop = loop->inner; subloop != NULL; subloop = subloop->next)
static edge
loop_edge_to_cancel (class loop *loop)
{
- vec<edge> exits;
unsigned i;
edge edge_to_cancel;
gimple_stmt_iterator gsi;
if (EDGE_COUNT (loop->latch->preds) > 1)
return NULL;
- exits = get_loop_exit_edges (loop);
+ auto_vec<edge> exits = get_loop_exit_edges (loop);
FOR_EACH_VEC_ELT (exits, i, edge_to_cancel)
{
if (edge_to_cancel->dest != loop->latch)
continue;
- exits.release ();
-
/* Verify that the code in loop latch does nothing that may end program
execution without really reaching the exit. This may include
non-pure/const function calls, EH statements, volatile ASMs etc. */
return NULL;
return edge_to_cancel;
}
- exits.release ();
return NULL;
}
by find_loop_niter_by_eval. Be sure to keep it for future. */
if (niter && TREE_CODE (niter) == INTEGER_CST)
{
- vec<edge> exits = get_loop_exit_edges (loop);
+ auto_vec<edge> exits = get_loop_exit_edges (loop);
record_niter_bound (loop, wi::to_widest (niter),
exit == single_likely_exit (loop, exits), true);
- exits.release ();
}
/* Force re-computation of loop bounds so we can remove redundant exits. */
FOR_EACH_LOOP (loop, 0)
{
- vec<edge> exit_edges = get_loop_exit_edges (loop);
+ auto_vec<edge> exit_edges = get_loop_exit_edges (loop);
loop_exits[loop->num] = BITMAP_ALLOC (&loop_renamer_obstack);
FOR_EACH_VEC_ELT (exit_edges, j, e)
bitmap_set_bit (loop_exits[loop->num], e->dest->index);
- exit_edges.release ();
}
}
find_loop_niter (class loop *loop, edge *exit)
{
unsigned i;
- vec<edge> exits = get_loop_exit_edges (loop);
+ auto_vec<edge> exits = get_loop_exit_edges (loop);
edge ex;
tree niter = NULL_TREE, aniter;
class tree_niter_desc desc;
continue;
}
}
- exits.release ();
return niter ? niter : chrec_dont_know;
}
if (loop->finite_p)
{
unsigned i;
- vec<edge> exits = get_loop_exit_edges (loop);
+ auto_vec<edge> exits = get_loop_exit_edges (loop);
edge ex;
/* If the loop has a normal exit, we can assume it will terminate. */
FOR_EACH_VEC_ELT (exits, i, ex)
if (!(ex->flags & (EDGE_EH | EDGE_ABNORMAL | EDGE_FAKE)))
{
- exits.release ();
if (dump_file)
fprintf (dump_file, "Assume loop %i to be finite: it has an exit "
"and -ffinite-loops is on.\n", loop->num);
return true;
}
-
- exits.release ();
}
return false;
find_loop_niter_by_eval (class loop *loop, edge *exit)
{
unsigned i;
- vec<edge> exits = get_loop_exit_edges (loop);
+ auto_vec<edge> exits = get_loop_exit_edges (loop);
edge ex;
tree niter = NULL_TREE, aniter;
/* Loops with multiple exits are expensive to handle and less important. */
if (!flag_expensive_optimizations
&& exits.length () > 1)
- {
- exits.release ();
- return chrec_dont_know;
- }
+ return chrec_dont_know;
FOR_EACH_VEC_ELT (exits, i, ex)
{
niter = aniter;
*exit = ex;
}
- exits.release ();
return niter ? niter : chrec_dont_know;
}
void
estimate_numbers_of_iterations (class loop *loop)
{
- vec<edge> exits;
tree niter, type;
unsigned i;
class tree_niter_desc niter_desc;
number_of_latch_executions (loop);
basic_block *body = get_loop_body (loop);
- exits = get_loop_exit_edges (loop, body);
+ auto_vec<edge> exits = get_loop_exit_edges (loop, body);
likely_exit = single_likely_exit (loop, exits);
FOR_EACH_VEC_ELT (exits, i, ex)
{
true, ex == likely_exit, true);
record_control_iv (loop, &niter_desc);
}
- exits.release ();
if (flag_aggressive_loop_optimizations)
infer_loop_bounds_from_undefined (loop, body);
static void
emit_mfence_after_loop (class loop *loop)
{
- vec<edge> exits = get_loop_exit_edges (loop);
+ auto_vec<edge> exits = get_loop_exit_edges (loop);
edge exit;
gcall *call;
gimple_stmt_iterator bsi;
gsi_insert_before (&bsi, call, GSI_NEW_STMT);
}
- exits.release ();
update_ssa (TODO_update_ssa_only_virtuals);
}
is a suitable place for it at each of the loop exits. */
if (FENCE_FOLLOWING_MOVNT != NULL_TREE)
{
- vec<edge> exits = get_loop_exit_edges (loop);
+ auto_vec<edge> exits = get_loop_exit_edges (loop);
unsigned i;
edge exit;
if ((exit->flags & EDGE_ABNORMAL)
&& exit->dest == EXIT_BLOCK_PTR_FOR_FN (cfun))
ret = false;
-
- exits.release ();
}
return ret;
auto_vec () { this->m_vec = NULL; }
auto_vec (size_t n) { this->create (n); }
~auto_vec () { this->release (); }
+
+ auto_vec (auto_vec&& r)
+ {
+ this->m_vec = r.m_vec;
+ r.m_vec = NULL;
+ }
+ void operator= (auto_vec&&) = delete;
};