[PATCH v4 2/3] ivopts: Remove target_reg_cost from reg pressure estimate.

Jovan Dmitrovic <[email protected]>
Newsgroups gmane.comp.gcc.patches
Message-ID <[email protected]>
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.

Also, the number of available registers is now not impacted by reserved
target registers, because there is no need to differentiate between cases
when those registers are used, as target_reg_cost is no longer a part
of the estimated cost.

gcc/ChangeLog:

        * tree-ssa-loop-ivopts.cc (ivopts_estimate_reg_pressure):
        Remove target_reg_cost from the computation of register pressure
        and target_res_regs from the computation of available registers.

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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.