The target_reg_cost plays a large part in the estimated cost for
register pressure, but it should be the eventual spilling that
has the most influence on the cost of storing/loading IV candidates and
invariants.
gcc/ChangeLog:
* tree-ssa-loop-ivopts.cc (ivopts_estimate_reg_pressure):
Remove target_reg_cost from the computation of register pressure.
Signed-off-by: Jovan Dmitrović <[email protected]>
---
gcc/tree-ssa-loop-ivopts.cc | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/gcc/tree-ssa-loop-ivopts.cc b/gcc/tree-ssa-loop-ivopts.cc
index 72f801a6fd89..ca06592190e0 100644
--- a/gcc/tree-ssa-loop-ivopts.cc
+++ b/gcc/tree-ssa-loop-ivopts.cc
@@ -6093,22 +6093,17 @@ ivopts_estimate_reg_pressure (struct ivopts_data *data,
unsigned n_invs,
available_regs = available_regs - target_clobbered_regs;
/* If we have enough registers. */
- if (regs_needed + target_res_regs < available_regs)
+ if (regs_needed <= available_regs)
cost = 0;
- /* If close to running out of registers, try to preserve them. */
- else if (regs_needed <= available_regs)
- cost = target_reg_cost [speed] * regs_needed;
/* If we run out of available registers but the number of candidates
does not, we penalize extra registers using target_spill_cost. */
else if (n_cands <= available_regs)
- cost = target_reg_cost [speed] * available_regs
- + target_spill_cost [speed] * (regs_needed - available_regs);
+ cost = target_spill_cost [speed] * (regs_needed - available_regs);
/* If the number of candidates runs out available registers, we penalize
extra candidate registers using target_spill_cost * 2. Because it is
more expensive to spill induction variable than invariant. */
else
- cost = target_reg_cost [speed] * available_regs
- + target_spill_cost [speed] * (n_cands - available_regs) * 2
+ cost = target_spill_cost [speed] * (n_cands - available_regs) * 2
+ target_spill_cost [speed] * (regs_needed - n_cands);
return cost;
--
2.34.1