public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jeff Law <law@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc(refs/vendors/riscv/heads/gcc-13-with-riscv-opts)] [RA]: Improve cost calculation of pseudos with equivalences
Date: Mon, 18 Sep 2023 18:26:40 +0000 (GMT)	[thread overview]
Message-ID: <20230918182640.B36473858C78@sourceware.org> (raw)

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;

                 reply	other threads:[~2023-09-18 18:26 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230918182640.B36473858C78@sourceware.org \
    --to=law@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).