public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jeff Law <law@redhat.com>
To: Peter Bergner <bergner@linux.ibm.com>
Cc: Segher Boessenkool <segher@kernel.crashing.org>,
	Pat Haugen <pthaugen@linux.ibm.com>,
	GCC Patches <gcc-patches@gcc.gnu.org>,
	David Edelsohn <dje.gcc@gmail.com>
Subject: Re: [PATCH] rs6000: Disable -fcaller-saves by default
Date: Tue, 25 Aug 2020 14:35:51 -0600	[thread overview]
Message-ID: <90a17292189abb90f3b624df3537274045997ed8.camel@redhat.com> (raw)
In-Reply-To: <f5815ccd-cf02-7edd-3005-62d30f763652@linux.ibm.com>

On Mon, 2020-08-10 at 11:11 -0500, Peter Bergner wrote:
> On 7/23/20 3:29 PM, Jeff Law wrote:
> > > > What's driving this change?
> > > 
> > > Peter noticed IRA allocates stuff to volatile registers while it is life
> > > through a call, and then LRA has to correct that, not optimal.
> > I can't recall if IRA or LRA handles the need to save them to the stack, but the
> > whole point is you can do much better sometimes by saving into the stack with the
> > caller-saves algorithm vs just giving up and spilling.
> > 
> > > > IRA will do a cost/benefit analysis to see using call clobbered registers like
> > > > this is profitable or not.  You're just turning the whole thing off.
> 
> Sorry for taking so long to reply.  I'm the guilty party for asking Pat
> to submit the patch. :-)  I was not aware IRA did that and just assumed
> it was a bug.  For now, consider the patch withdrawn.  That said, I
> will have to look at that cost computation, especially since when I
> last looked, IRA does not count potential prologue/epilogue save/restore
> insns if it were to assign a non-volatile register when computing reg
> costs.  That would seem to be an important consideration here.
No worries.  Yea, you want to count the prologue/epilogue, as well as the
saves/restores at the call points  (which need frequency scaling and accounting
for saves which don't need to happen because a prior save is sufficient to cover
more than one call), etc.

I think much of this code is still in caller-save.c.  It's been eons since I
worked on it, but I can probably get reacquainted with the implementation if you
have questions



> I'll note this all came about when I was looking at PR96017, which is
> due to not shrink-wrapping a pseudo.  That was due to it being live
> across a call.  I first I thought (for the 2nd test case, not the original
> one) split_live_ranges_for_shrink_wrap() was nicely splitting the pseudo
> for us, but it must have been the caller-saves algorithm you mention above.
> However, that code doesn't handle the original test case, which I think
> it should.
> 
> My thought for that bug was to introduce some extra splitting before RA
> (maybe as part of split_live_ranges_for_shrink_wrap?) where we split
> pseudos that are live across a call, but that have at least one path
> to the exit that doesn't cross a call.  However, if we can beef up
> the caller-saves cost computation, maybe that would work too?
I've gone back and forth on pre allocation splitting as well as post-allocating
splitting and re-allocation.   I could argue either side of that discussion --
given we've got a bit of special code for splitting to help shrink wrapping,
maybe that's the best place if we need to do splitting before RA since this was
triggered by digging into a shrink-wrapping problem.

I'd probably start by making sure the cost computation is sane though.

Jeff


  reply	other threads:[~2020-08-25 20:35 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-23 19:25 Pat Haugen
2020-07-23 19:42 ` Jeff Law
2020-07-23 20:19   ` Segher Boessenkool
2020-07-23 20:29     ` Jeff Law
2020-07-23 20:43       ` Segher Boessenkool
2020-08-10 16:11       ` Peter Bergner
2020-08-25 20:35         ` Jeff Law [this message]
2020-08-26 20:58           ` Segher Boessenkool
2020-08-26 21:10             ` Jeff Law

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=90a17292189abb90f3b624df3537274045997ed8.camel@redhat.com \
    --to=law@redhat.com \
    --cc=bergner@linux.ibm.com \
    --cc=dje.gcc@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=pthaugen@linux.ibm.com \
    --cc=segher@kernel.crashing.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).