summaryrefslogtreecommitdiff
path: root/gcc/loop-invariant.c
diff options
context:
space:
mode:
authorrakdver <rakdver@138bc75d-0d04-0410-961f-82ee72b054a4>2007-04-17 16:42:29 +0000
committerrakdver <rakdver@138bc75d-0d04-0410-961f-82ee72b054a4>2007-04-17 16:42:29 +0000
commit25153338ebbedbe0f614bc9b994fa72c6fb38699 (patch)
tree0a31c59ebc8695e61c56119d3a3890c7117e0a43 /gcc/loop-invariant.c
parentb9c7fce7adefe388cca987a0633e2e80be25084e (diff)
downloadgcc-25153338ebbedbe0f614bc9b994fa72c6fb38699.tar.gz
PR rtl-optimization/31360
* cfgloopanal.c (target_small_cost, target_pres_cost): Removed. (target_reg_cost): New. (init_set_costs): Initialize target_reg_cost. Add comments regarding the rationale of the costs. (global_cost_for_size): Renamed to... (estimate_reg_pressure_cost): ... and simplify. Decrease importance of register pressure. * tree-ssa-loop-ivopts.c (ivopts_global_cost_for_size): Use estimate_reg_pressure_cost. Add number of ivs. (determine_set_costs): Dump target_reg_cost. * loop-invariant.c (gain_for_invariant): Use estimate_reg_pressure_cost. Removed n_inv_uses argument. (best_gain_for_invariant, find_invariants_to_move): Remove n_inv_uses. * cfgloop.h (target_small_cost, target_pres_cost): Removed. (target_reg_cost): Declare. (global_cost_for_size): Declaration removed. (estimate_reg_pressure_cost): Declare. * gcc.dg/loop-7.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@123919 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/loop-invariant.c')
-rw-r--r--gcc/loop-invariant.c46
1 files changed, 16 insertions, 30 deletions
diff --git a/gcc/loop-invariant.c b/gcc/loop-invariant.c
index 4c6e8bc9f9c..304e424cf2d 100644
--- a/gcc/loop-invariant.c
+++ b/gcc/loop-invariant.c
@@ -983,37 +983,34 @@ get_inv_cost (struct invariant *inv, int *comp_cost, unsigned *regs_needed)
}
/* Calculates gain for eliminating invariant INV. REGS_USED is the number
- of registers used in the loop, N_INV_USES is the number of uses of
- invariants, NEW_REGS is the number of new variables already added due to
- the invariant motion. The number of registers needed for it is stored in
- *REGS_NEEDED. */
+ of registers used in the loop, NEW_REGS is the number of new variables
+ already added due to the invariant motion. The number of registers needed
+ for it is stored in *REGS_NEEDED. */
static int
gain_for_invariant (struct invariant *inv, unsigned *regs_needed,
- unsigned new_regs, unsigned regs_used, unsigned n_inv_uses)
+ unsigned new_regs, unsigned regs_used)
{
int comp_cost, size_cost;
get_inv_cost (inv, &comp_cost, regs_needed);
actual_stamp++;
- size_cost = (global_cost_for_size (new_regs + *regs_needed,
- regs_used, n_inv_uses)
- - global_cost_for_size (new_regs, regs_used, n_inv_uses));
+ size_cost = (estimate_reg_pressure_cost (new_regs + *regs_needed, regs_used)
+ - estimate_reg_pressure_cost (new_regs, regs_used));
return comp_cost - size_cost;
}
/* Finds invariant with best gain for moving. Returns the gain, stores
the invariant in *BEST and number of registers needed for it to
- *REGS_NEEDED. REGS_USED is the number of registers used in
- the loop, N_INV_USES is the number of uses of invariants. NEW_REGS
- is the number of new variables already added due to invariant motion. */
+ *REGS_NEEDED. REGS_USED is the number of registers used in the loop.
+ NEW_REGS is the number of new variables already added due to invariant
+ motion. */
static int
best_gain_for_invariant (struct invariant **best, unsigned *regs_needed,
- unsigned new_regs, unsigned regs_used,
- unsigned n_inv_uses)
+ unsigned new_regs, unsigned regs_used)
{
struct invariant *inv;
int gain = 0, again;
@@ -1028,8 +1025,7 @@ best_gain_for_invariant (struct invariant **best, unsigned *regs_needed,
if (inv->eqto != inv->invno)
continue;
- again = gain_for_invariant (inv, &aregs_needed,
- new_regs, regs_used, n_inv_uses);
+ again = gain_for_invariant (inv, &aregs_needed, new_regs, regs_used);
if (again > gain)
{
gain = again;
@@ -1070,19 +1066,16 @@ set_move_mark (unsigned invno)
static void
find_invariants_to_move (void)
{
- unsigned i, regs_used, n_inv_uses, regs_needed = 0, new_regs;
+ unsigned i, regs_used, regs_needed = 0, new_regs;
struct invariant *inv = NULL;
unsigned int n_regs = DF_REG_SIZE (df);
if (!VEC_length (invariant_p, invariants))
return;
- /* Now something slightly more involved. First estimate the number of used
- registers. */
- n_inv_uses = 0;
-
- /* We do not really do a good job in this estimation; put some initial bound
- here to stand for induction variables etc. that we do not detect. */
+ /* We do not really do a good job in estimating number of registers used;
+ we put some initial bound here to stand for induction variables etc.
+ that we do not detect. */
regs_used = 2;
for (i = 0; i < n_regs; i++)
@@ -1094,15 +1087,8 @@ find_invariants_to_move (void)
}
}
- for (i = 0; VEC_iterate (invariant_p, invariants, i, inv); i++)
- {
- if (inv->def)
- n_inv_uses += inv->def->n_uses;
- }
-
new_regs = 0;
- while (best_gain_for_invariant (&inv, &regs_needed,
- new_regs, regs_used, n_inv_uses) > 0)
+ while (best_gain_for_invariant (&inv, &regs_needed, new_regs, regs_used) > 0)
{
set_move_mark (inv->invno);
new_regs += regs_needed;