public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jskumari at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug rtl-optimization/110071] New: improve_allocation() routine should consider save/restore cost of callee-save registers
Date: Thu, 01 Jun 2023 07:55:01 +0000	[thread overview]
Message-ID: <bug-110071-4@http.gcc.gnu.org/bugzilla/> (raw)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110071

            Bug ID: 110071
           Summary: improve_allocation() routine should consider
                    save/restore cost of callee-save registers
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jskumari at gcc dot gnu.org
  Target Milestone: ---

For the following test:

long
foo (long i, long cond)
{
  if (cond)
    bar ();
  return i+1;
}

Input RTL to IRA:

BB2:
  set r123, r4
  set r122, r3
  set r120, compare(r123, 0)
  set r118, r122
  if r120 jump BB4 else jump BB3
BB3:
  call bar()
BB4:
  set r3, r118+1
  return r3

IRA assigns r31 to r118.
Since r31 is a callee save register in powerpc, we need to generate
spill/restore code.

This assignment of r31 to r118 causes shrink wrap to fail for this test.
Since r31 is assigned to r118, BB2 requires a prolog and shrink wrap fails.

In the IRA pass, after graph coloring, r118 gets assigned to r3.
The routine improve_allocation() is called after graph coloring. This routine
changes the assignment of r118 to r31.

In improve_allocation() routine, IRA checks for each allocno if spilling any
conflicting allocnos can improve the allocation of this allocno. This routine
computes the cost improvement for usage of each profitable hard register for a
given allocno.

The existing code in improve_allocation() does not consider the save/restore
costs of callee save registers while computing the cost improvement.

This bug is for adding save/restore costs while computing cost improvement.

Save/restore costs should be considered only for the first assignment of a
callee save register. Subsequent assignments of the same register do not need
to consider this cost.

             reply	other threads:[~2023-06-01  7:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-01  7:55 jskumari at gcc dot gnu.org [this message]
2023-09-20  1:55 ` [Bug rtl-optimization/110071] " cvs-commit at gcc dot gnu.org
2024-02-01  8:52 ` jskumari at gcc dot gnu.org
2024-02-01  8:54 ` jskumari at gcc dot gnu.org

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=bug-110071-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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).