From 1136cae41bea892b33586aa52e90889b736fce53 Mon Sep 17 00:00:00 2001 From: Bin Cheng Date: Tue, 2 May 2017 16:14:53 +0000 Subject: [PATCH] tree-ssa-loop-ivopts.c (struct iv_ca): Rename n_regs to n_invs. * 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. From-SVN: r247515 --- gcc/ChangeLog | 9 +++++++++ gcc/tree-ssa-loop-ivopts.c | 33 +++++++++++++++------------------ 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 28cde9e929f..04323a3cfc1 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2017-05-02 Bin Cheng + + * 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 * tree-ssa-loop-ivopts.c (struct walk_tree_data): New. diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c index 3a5b1b9f7c8..409a35dea73 100644 --- a/gcc/tree-ssa-loop-ivopts.c +++ b/gcc/tree-ssa-loop-ivopts.c @@ -612,8 +612,9 @@ struct iv_ca /* 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; @@ -5989,15 +5990,17 @@ determine_iv_costs (struct ivopts_data *data) 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. */ @@ -6100,9 +6103,7 @@ iv_ca_recount_cost (struct ivopts_data *data, struct iv_ca *ivs) 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; } @@ -6123,7 +6124,7 @@ iv_ca_set_remove_invs (struct iv_ca *ivs, bitmap invs, unsigned *n_inv_uses) { n_inv_uses[iid]--; if (n_inv_uses[iid] == 0) - ivs->n_regs--; + ivs->n_invs--; } } @@ -6148,10 +6149,8 @@ iv_ca_set_no_cp (struct ivopts_data *data, struct iv_ca *ivs, 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); } @@ -6178,7 +6177,7 @@ iv_ca_set_add_invs (struct iv_ca *ivs, bitmap invs, unsigned *n_inv_uses) { n_inv_uses[iid]++; if (n_inv_uses[iid] == 1) - ivs->n_regs++; + ivs->n_invs++; } } @@ -6206,10 +6205,8 @@ iv_ca_set_cp (struct ivopts_data *data, struct iv_ca *ivs, 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); } @@ -6421,7 +6418,7 @@ iv_ca_new (struct ivopts_data *data) 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); -- 2.30.2