[gcc r17-2277] ivopts: Set register pressure cost to zero if there are enough registers.

Jeff Law via Gcc-cvs <[email protected]>
Newsgroups gmane.comp.gcc.cvs
Message-ID <[email protected]>
https://gcc.gnu.org/g:6d97581286030449420dc4ee79612dd256067e2c

commit r17-2277-g6d97581286030449420dc4ee79612dd256067e2c
Author: Jovan Dmitrovic <[email protected]>
Date:   Thu Jul 9 07:31:17 2026 -0600

    ivopts: Set register pressure cost to zero if there are enough registers.
    
    In function ivopts_estimate_reg_pressure, return zero if there are
    enough registers available so that spilling is not necessary.
    
    gcc/ChangeLog:
    
            * tree-ssa-loop-ivopts.cc (ivopts_estimate_reg_pressure):
            Return zero if there are enough registers to store new
            invariants and induction variables.
    
    Suggested-by:  Richard Biener <[email protected]>
    Signed-off-by: Jovan Dmitrović <[email protected]>
    Signed-off-by: Djordje Todorović <[email protected]>
    Signed-off-by: Chao-Ying Fu <[email protected]>
    Signed-off-by: Radosav Krunić <[email protected]>

Diff:
---
 gcc/tree-ssa-loop-ivopts.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/tree-ssa-loop-ivopts.cc b/gcc/tree-ssa-loop-ivopts.cc
index f8dfc77de4ae..55756c2d90db 100644
--- a/gcc/tree-ssa-loop-ivopts.cc
+++ b/gcc/tree-ssa-loop-ivopts.cc
@@ -6094,7 +6094,7 @@ ivopts_estimate_reg_pressure (struct ivopts_data *data, unsigned n_invs,
 
   /* If we have enough registers.  */
   if (regs_needed + target_res_regs < available_regs)
-    cost = n_new;
+    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;
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.