+2017-05-02 Bin Cheng <bin.cheng@arm.com>
+
+ * tree-ssa-loop-ivopts.c (struct iv_ca): Rename n_regs to n_invs.
+ (ivopts_global_cost_for_size): Rename parameter and update uses.
+ (iv_ca_recount_cost): Update uses.
+ (iv_ca_set_remove_invs, iv_ca_set_no_cp): Record invariants and
+ candidates seperately in n_invs and n_cands.
+ (iv_ca_set_add_invs, iv_ca_set_cp, iv_ca_new): Ditto.
+
2017-05-02 Bin Cheng <bin.cheng@arm.com>
* tree-ssa-loop-ivopts.c (struct walk_tree_data): New.
/* The number of candidates in the set. */
unsigned n_cands;
- /* Total number of registers needed. */
- unsigned n_regs;
+ /* The number of invariants needed, including both invariant variants and
+ invariant expressions. */
+ unsigned n_invs;
/* Total cost of expressing uses. */
comp_cost cand_use_cost;
fprintf (dump_file, "\n");
}
-/* Calculates cost for having SIZE induction variables. */
+/* Calculates cost for having N_REGS registers. This number includes
+ induction variables, invariant variables and invariant expressions. */
static unsigned
-ivopts_global_cost_for_size (struct ivopts_data *data, unsigned size)
+ivopts_global_cost_for_size (struct ivopts_data *data, unsigned n_regs)
{
- /* We add size to the cost, so that we prefer eliminating ivs
- if possible. */
- return size + estimate_reg_pressure_cost (size, data->regs_used, data->speed,
- data->body_includes_call);
+ unsigned cost = estimate_reg_pressure_cost (n_regs,
+ data->regs_used, data->speed,
+ data->body_includes_call);
+ /* Add n_regs to the cost, so that we prefer eliminating ivs if possible. */
+ return n_regs + cost;
}
/* For each size of the induction variable set determine the penalty. */
comp_cost cost = ivs->cand_use_cost;
cost += ivs->cand_cost;
-
- cost += ivopts_global_cost_for_size (data, ivs->n_regs);
-
+ cost += ivopts_global_cost_for_size (data, ivs->n_invs + ivs->n_cands);
ivs->cost = cost;
}
{
n_inv_uses[iid]--;
if (n_inv_uses[iid] == 0)
- ivs->n_regs--;
+ ivs->n_invs--;
}
}
if (ivs->n_cand_uses[cid] == 0)
{
bitmap_clear_bit (ivs->cands, cid);
- ivs->n_regs--;
ivs->n_cands--;
ivs->cand_cost -= cp->cand->cost;
-
iv_ca_set_remove_invs (ivs, cp->cand->inv_vars, ivs->n_inv_var_uses);
}
{
n_inv_uses[iid]++;
if (n_inv_uses[iid] == 1)
- ivs->n_regs++;
+ ivs->n_invs++;
}
}
if (ivs->n_cand_uses[cid] == 1)
{
bitmap_set_bit (ivs->cands, cid);
- ivs->n_regs++;
ivs->n_cands++;
ivs->cand_cost += cp->cand->cost;
-
iv_ca_set_add_invs (ivs, cp->cand->inv_vars, ivs->n_inv_var_uses);
}
nw->n_cand_uses = XCNEWVEC (unsigned, data->vcands.length ());
nw->cands = BITMAP_ALLOC (NULL);
nw->n_cands = 0;
- nw->n_regs = 0;
+ nw->n_invs = 0;
nw->cand_use_cost = no_cost;
nw->cand_cost = 0;
nw->n_inv_var_uses = XCNEWVEC (unsigned, data->max_inv_var_id + 1);