diff options
Diffstat (limited to 'gcc/cfgloopanal.c')
-rw-r--r-- | gcc/cfgloopanal.c | 62 |
1 files changed, 34 insertions, 28 deletions
diff --git a/gcc/cfgloopanal.c b/gcc/cfgloopanal.c index db5bd2a62b9..d59fa2fb505 100644 --- a/gcc/cfgloopanal.c +++ b/gcc/cfgloopanal.c @@ -295,7 +295,7 @@ get_loop_level (const struct loop *loop) /* Returns estimate on cost of computing SEQ. */ static unsigned -seq_cost (const_rtx seq) +seq_cost (const_rtx seq, bool speed) { unsigned cost = 0; rtx set; @@ -304,7 +304,7 @@ seq_cost (const_rtx seq) { set = single_set (seq); if (set) - cost += rtx_cost (set, SET); + cost += rtx_cost (set, SET, speed); else cost++; } @@ -317,10 +317,10 @@ seq_cost (const_rtx seq) unsigned target_avail_regs; /* Number of available registers. */ unsigned target_res_regs; /* Number of registers reserved for temporary expressions. */ -unsigned target_reg_cost; /* The cost for register when there still +unsigned target_reg_cost[2]; /* The cost for register when there still is some reserve, but we are approaching the number of available registers. */ -unsigned target_spill_cost; /* The cost for register when we need +unsigned target_spill_cost[2]; /* The cost for register when we need to spill. */ /* Initialize the constants for computing set costs. */ @@ -328,6 +328,7 @@ unsigned target_spill_cost; /* The cost for register when we need void init_set_costs (void) { + int speed; rtx seq; rtx reg1 = gen_raw_REG (SImode, FIRST_PSEUDO_REGISTER); rtx reg2 = gen_raw_REG (SImode, FIRST_PSEUDO_REGISTER + 1); @@ -343,27 +344,32 @@ init_set_costs (void) target_res_regs = 3; - /* Set up the costs for using extra registers: - - 1) If not many free registers remain, we should prefer having an - additional move to decreasing the number of available registers. - (TARGET_REG_COST). - 2) If no registers are available, we need to spill, which may require - storing the old value to memory and loading it back - (TARGET_SPILL_COST). */ - - start_sequence (); - emit_move_insn (reg1, reg2); - seq = get_insns (); - end_sequence (); - target_reg_cost = seq_cost (seq); - - start_sequence (); - emit_move_insn (mem, reg1); - emit_move_insn (reg2, mem); - seq = get_insns (); - end_sequence (); - target_spill_cost = seq_cost (seq); + for (speed = 0; speed < 2; speed++) + { + crtl->maybe_hot_insn_p = speed; + /* Set up the costs for using extra registers: + + 1) If not many free registers remain, we should prefer having an + additional move to decreasing the number of available registers. + (TARGET_REG_COST). + 2) If no registers are available, we need to spill, which may require + storing the old value to memory and loading it back + (TARGET_SPILL_COST). */ + + start_sequence (); + emit_move_insn (reg1, reg2); + seq = get_insns (); + end_sequence (); + target_reg_cost [speed] = seq_cost (seq, speed); + + start_sequence (); + emit_move_insn (mem, reg1); + emit_move_insn (reg2, mem); + seq = get_insns (); + end_sequence (); + target_spill_cost [speed] = seq_cost (seq, speed); + } + default_rtl_profile (); } /* Estimates cost of increased register pressure caused by making N_NEW new @@ -371,7 +377,7 @@ init_set_costs (void) around the loop. */ unsigned -estimate_reg_pressure_cost (unsigned n_new, unsigned n_old) +estimate_reg_pressure_cost (unsigned n_new, unsigned n_old, bool speed) { unsigned cost; unsigned regs_needed = n_new + n_old; @@ -384,11 +390,11 @@ estimate_reg_pressure_cost (unsigned n_new, unsigned n_old) if (regs_needed <= target_avail_regs) /* If we are close to running out of registers, try to preserve them. */ - cost = target_reg_cost * n_new; + cost = target_reg_cost [speed] * n_new; else /* If we run out of registers, it is very expensive to add another one. */ - cost = target_spill_cost * n_new; + cost = target_spill_cost [speed] * n_new; if (optimize && flag_ira && (flag_ira_algorithm == IRA_ALGORITHM_REGIONAL || flag_ira_algorithm == IRA_ALGORITHM_MIXED) |