public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/vendors/riscv/heads/gcc-13-with-riscv-opts)] [RA]: Improve cost calculation of pseudos with equivalences
@ 2023-09-18 18:26 Jeff Law
  0 siblings, 0 replies; only message in thread
From: Jeff Law @ 2023-09-18 18:26 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:2c80f25679657032a65ecd3d18650167617a5679

commit 2c80f25679657032a65ecd3d18650167617a5679
Author: Vladimir N. Makarov <vmakarov@redhat.com>
Date:   Thu Sep 14 10:26:48 2023 -0400

    [RA]: Improve cost calculation of pseudos with equivalences
    
    RISCV target developers reported that RA can spill pseudo used in a
    loop although there are enough registers to assign.  It happens when
    the pseudo has an equivalence outside the loop and the equivalence is
    not merged into insns using the pseudo.  IRA sets up that memory cost
    to zero when the pseudo has an equivalence and it means that the
    pseudo will be probably spilled.  This approach worked well for i686
    (different approaches were benchmarked long time ago on spec2k).
    Although common sense says that the code is wrong and this was
    confirmed by RISCV developers.
    
    I've tried the following patch on I7-9700k and it improved spec17 fp
    by 1.5% (21.1 vs 20.8) although spec17 int is a bit worse by 0.45%
    (8.54 vs 8.58).  The average generated code size is practically the
    same (0.001% difference).
    
    In the future we probably need to try more sophisticated cost
    calculation which should take into account that the equiv can not be
    combined in usage insns and the costs of reloads because of this.
    
    gcc/ChangeLog:
    
            * ira-costs.cc (find_costs_and_classes): Decrease memory cost
            by equiv savings.
    
    (cherry picked from commit 3c834d85f2ec42c60995c2b678196a06cb744959)

Diff:
---
 gcc/ira-costs.cc | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/gcc/ira-costs.cc b/gcc/ira-costs.cc
index bdb1356af91..52c9c0b7608 100644
--- a/gcc/ira-costs.cc
+++ b/gcc/ira-costs.cc
@@ -1940,15 +1940,8 @@ find_costs_and_classes (FILE *dump_file)
 	    }
 	  if (i >= first_moveable_pseudo && i < last_moveable_pseudo)
 	    i_mem_cost = 0;
-	  else if (equiv_savings < 0)
-	    i_mem_cost = -equiv_savings;
-	  else if (equiv_savings > 0)
-	    {
-	      i_mem_cost = 0;
-	      for (k = cost_classes_ptr->num - 1; k >= 0; k--)
-		i_costs[k] += equiv_savings;
-	    }
-
+	  else
+	    i_mem_cost -= equiv_savings;
 	  best_cost = (1 << (HOST_BITS_PER_INT - 2)) - 1;
 	  best = ALL_REGS;
 	  alt_class = NO_REGS;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-09-18 18:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-18 18:26 [gcc(refs/vendors/riscv/heads/gcc-13-with-riscv-opts)] [RA]: Improve cost calculation of pseudos with equivalences Jeff Law

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).