Commit 2c407426 by Bin Cheng Committed by Bin Cheng

tree-ssa-loop-ivopts.c (iv_ca_narrow): New parameter.


	* tree-ssa-loop-ivopts.c (iv_ca_narrow): New parameter.
	Start narrowing with START.  Apply candidate-use pair
	and check overall cost in narrowing.
	(iv_ca_prune): Pass new argument.

From-SVN: r206552
parent 730e4093
2014-01-11 Bin Cheng <bin.cheng@arm.com>
* tree-ssa-loop-ivopts.c (iv_ca_narrow): New parameter.
Start narrowing with START. Apply candidate-use pair
and check overall cost in narrowing.
(iv_ca_prune): Pass new argument.
2014-01-10 Jeff Law <law@redhat.com> 2014-01-10 Jeff Law <law@redhat.com>
PR middle-end/59743 PR middle-end/59743
......
...@@ -5733,18 +5733,20 @@ iv_ca_extend (struct ivopts_data *data, struct iv_ca *ivs, ...@@ -5733,18 +5733,20 @@ iv_ca_extend (struct ivopts_data *data, struct iv_ca *ivs,
} }
/* Try narrowing set IVS by removing CAND. Return the cost of /* Try narrowing set IVS by removing CAND. Return the cost of
the new set and store the differences in DELTA. */ the new set and store the differences in DELTA. START is
the candidate with which we start narrowing. */
static comp_cost static comp_cost
iv_ca_narrow (struct ivopts_data *data, struct iv_ca *ivs, iv_ca_narrow (struct ivopts_data *data, struct iv_ca *ivs,
struct iv_cand *cand, struct iv_ca_delta **delta) struct iv_cand *cand, struct iv_cand *start,
struct iv_ca_delta **delta)
{ {
unsigned i, ci; unsigned i, ci;
struct iv_use *use; struct iv_use *use;
struct cost_pair *old_cp, *new_cp, *cp; struct cost_pair *old_cp, *new_cp, *cp;
bitmap_iterator bi; bitmap_iterator bi;
struct iv_cand *cnd; struct iv_cand *cnd;
comp_cost cost; comp_cost cost, best_cost, acost;
*delta = NULL; *delta = NULL;
for (i = 0; i < n_iv_uses (data); i++) for (i = 0; i < n_iv_uses (data); i++)
...@@ -5755,13 +5757,15 @@ iv_ca_narrow (struct ivopts_data *data, struct iv_ca *ivs, ...@@ -5755,13 +5757,15 @@ iv_ca_narrow (struct ivopts_data *data, struct iv_ca *ivs,
if (old_cp->cand != cand) if (old_cp->cand != cand)
continue; continue;
new_cp = NULL; best_cost = iv_ca_cost (ivs);
/* Start narrowing with START. */
new_cp = get_use_iv_cost (data, use, start);
if (data->consider_all_candidates) if (data->consider_all_candidates)
{ {
EXECUTE_IF_SET_IN_BITMAP (ivs->cands, 0, ci, bi) EXECUTE_IF_SET_IN_BITMAP (ivs->cands, 0, ci, bi)
{ {
if (ci == cand->id) if (ci == cand->id || (start && ci == start->id))
continue; continue;
cnd = iv_cand (data, ci); cnd = iv_cand (data, ci);
...@@ -5770,20 +5774,21 @@ iv_ca_narrow (struct ivopts_data *data, struct iv_ca *ivs, ...@@ -5770,20 +5774,21 @@ iv_ca_narrow (struct ivopts_data *data, struct iv_ca *ivs,
if (!cp) if (!cp)
continue; continue;
if (!iv_ca_has_deps (ivs, cp)) iv_ca_set_cp (data, ivs, use, cp);
continue; acost = iv_ca_cost (ivs);
if (!cheaper_cost_pair (cp, new_cp)) if (compare_costs (acost, best_cost) < 0)
continue; {
best_cost = acost;
new_cp = cp; new_cp = cp;
}
} }
} }
else else
{ {
EXECUTE_IF_AND_IN_BITMAP (use->related_cands, ivs->cands, 0, ci, bi) EXECUTE_IF_AND_IN_BITMAP (use->related_cands, ivs->cands, 0, ci, bi)
{ {
if (ci == cand->id) if (ci == cand->id || (start && ci == start->id))
continue; continue;
cnd = iv_cand (data, ci); cnd = iv_cand (data, ci);
...@@ -5791,15 +5796,19 @@ iv_ca_narrow (struct ivopts_data *data, struct iv_ca *ivs, ...@@ -5791,15 +5796,19 @@ iv_ca_narrow (struct ivopts_data *data, struct iv_ca *ivs,
cp = get_use_iv_cost (data, use, cnd); cp = get_use_iv_cost (data, use, cnd);
if (!cp) if (!cp)
continue; continue;
if (!iv_ca_has_deps (ivs, cp))
continue;
if (!cheaper_cost_pair (cp, new_cp)) iv_ca_set_cp (data, ivs, use, cp);
continue; acost = iv_ca_cost (ivs);
new_cp = cp; if (compare_costs (acost, best_cost) < 0)
{
best_cost = acost;
new_cp = cp;
}
} }
} }
/* Restore to old cp for use. */
iv_ca_set_cp (data, ivs, use, old_cp);
if (!new_cp) if (!new_cp)
{ {
...@@ -5841,7 +5850,7 @@ iv_ca_prune (struct ivopts_data *data, struct iv_ca *ivs, ...@@ -5841,7 +5850,7 @@ iv_ca_prune (struct ivopts_data *data, struct iv_ca *ivs,
if (cand == except_cand) if (cand == except_cand)
continue; continue;
acost = iv_ca_narrow (data, ivs, cand, &act_delta); acost = iv_ca_narrow (data, ivs, cand, except_cand, &act_delta);
if (compare_costs (acost, best_cost) < 0) if (compare_costs (acost, best_cost) < 0)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment