/* The maximum invariant id. */
unsigned max_inv_id;
+ /* Obstack for iv structure. */
+ struct obstack iv_obstack;
+
/* Whether to consider just related and important candidates when replacing a
use. */
bool consider_all_candidates;
data->inv_expr_id = 0;
data->name_expansion_cache = NULL;
decl_rtl_to_reset.create (20);
+ gcc_obstack_init (&data->iv_obstack);
}
/* Returns a memory object to that EXPR points. In case we are able to
for loop LOOP. NO_OVERFLOW implies the iv doesn't overflow. */
static struct iv *
-alloc_iv (tree base, tree step, bool no_overflow = false)
+alloc_iv (struct ivopts_data *data, tree base, tree step,
+ bool no_overflow = false)
{
tree expr = base;
- struct iv *iv = XCNEW (struct iv);
+ struct iv *iv = (struct iv*) obstack_alloc (&data->iv_obstack,
+ sizeof (struct iv));
gcc_assert (step != NULL_TREE);
/* Lower address expression in base except ones with DECL_P as operand.
gcc_assert (!info->iv);
bitmap_set_bit (data->relevant, SSA_NAME_VERSION (iv));
- info->iv = alloc_iv (base, step, no_overflow);
+ info->iv = alloc_iv (data, base, step, no_overflow);
info->iv->ssa_name = iv;
}
find_interesting_uses_op (struct ivopts_data *data, tree op)
{
struct iv *iv;
- struct iv *civ;
gimple stmt;
struct iv_use *use;
}
iv->have_use_for = true;
- civ = XNEW (struct iv);
- *civ = *iv;
-
stmt = SSA_NAME_DEF_STMT (op);
gcc_assert (gimple_code (stmt) == GIMPLE_PHI
|| is_gimple_assign (stmt));
- use = record_use (data, NULL, civ, stmt, USE_NONLINEAR_EXPR);
+ use = record_use (data, NULL, iv, stmt, USE_NONLINEAR_EXPR);
iv->use_id = use->id;
return use;
find_interesting_uses_cond (struct ivopts_data *data, gimple stmt)
{
tree *var_p, *bound_p;
- struct iv *var_iv, *civ;
+ struct iv *var_iv;
if (!extract_cond_operands (data, stmt, &var_p, &bound_p, &var_iv, NULL))
{
return;
}
- civ = XNEW (struct iv);
- *civ = *var_iv;
- record_use (data, NULL, civ, stmt, USE_COMPARE);
+ record_use (data, NULL, var_iv, stmt, USE_COMPARE);
}
/* Returns the outermost loop EXPR is obviously invariant in
}
}
- civ = alloc_iv (base, step);
+ civ = alloc_iv (data, base, step);
record_group_use (data, op_p, civ, stmt, USE_ADDRESS);
return;
if (!base && !step)
cand->iv = NULL;
else
- cand->iv = alloc_iv (base, step);
+ cand->iv = alloc_iv (data, base, step);
cand->pos = pos;
if (pos != IP_ORIGINAL && cand->iv)
struct version_info *info;
info = ver_info (data, i);
- free (info->iv);
info->iv = NULL;
info->has_nonlin_use = false;
info->preserve_biv = false;
gcc_assert (sub->related_cands == NULL);
gcc_assert (sub->n_map_members == 0 && sub->cost_map == NULL);
- free (sub->iv);
pre = sub;
sub = sub->next;
free (pre);
}
- free (use->iv);
BITMAP_FREE (use->related_cands);
for (j = 0; j < use->n_map_members; j++)
if (use->cost_map[j].depends_on)
{
struct iv_cand *cand = iv_cand (data, i);
- free (cand->iv);
if (cand->depends_on)
BITMAP_FREE (cand->depends_on);
free (cand);
delete data->inv_expr_tab;
data->inv_expr_tab = NULL;
free_affine_expand_cache (&data->name_expansion_cache);
+ obstack_free (&data->iv_obstack, NULL);
}
/* Returns true if the loop body BODY includes any function calls. */