From: Alan Modra <amodra@gmail.com>
To: Segher Boessenkool <segher@kernel.crashing.org>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [RS6000] make PLT loads volatile
Date: Sat, 14 Mar 2020 09:30:02 +1030 [thread overview]
Message-ID: <20200313230002.GB23597@bubble.grove.modra.org> (raw)
In-Reply-To: <20200313154038.GR22482@gate.crashing.org>
On Fri, Mar 13, 2020 at 10:40:38AM -0500, Segher Boessenkool wrote:
> Hi!
>
> On Fri, Mar 13, 2020 at 10:06:01AM +1030, Alan Modra wrote:
> > On Thu, Mar 12, 2020 at 11:57:17AM -0500, Segher Boessenkool wrote:
> > > On Thu, Mar 12, 2020 at 01:18:50PM +1030, Alan Modra wrote:
> > > > With lazy PLT resolution the first load of a PLT entry may be a value
> > > > pointing at a resolver stub. gcc's loop processing can result in the
> > > > PLT load in inline PLT calls being hoisted out of a loop in the
> > > > mistaken idea that this is an optimisation. It isn't. If the value
> > > > hoisted was that for a resolver stub then every call to that function
> > > > in the loop will go via the resolver, slowing things down quite
> > > > dramatically.
> > > >
> > > > The PLT really is volatile, so teach gcc about that.
> > >
> > > It would be nice if we could keep it cached after it has been resolved
> > > once, this has potential for regressing performance if we don't? And
> > > LD_BIND_NOW should keep working just as fast as it is now, too?
> >
> > Using a call-saved register to cache a load out of the PLT looks
> > really silly
>
> Who said anything about using call-saved registers? GCC will usually
> make a stack slot for this, and only use a non-volatile register when
> that is profitable. (I know it is a bit too aggressive with it, but
> that is a generic problem).
Using a stack slot comes about due to hoisting then running out of
call-saved registers in the loop. Score another reason not to hoist
PLT loads.
> > when the inline PLT call is turned back into a direct
> > call by the linker.
>
> Ah, so yeah, for direct calls we do not want this. I was thinking this
> was about indirect calls (via a bctrl that is), dunno how I got that
> misperception. Sorry.
>
> What is this like for indirect calls (at C level)? Does your patch do
> anything to those?
No effect at all. To put your mind at rest on this point you can
verify quite easily by noticing that UNSPECV_PLT* is only generated in
rs6000_longcall_ref, and calls to that function are conditional on
GET_CODE (func_desc) == SYMBOL_REF.
--
Alan Modra
Australia Development Lab, IBM
next prev parent reply other threads:[~2020-03-13 23:00 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-12 2:48 Alan Modra
2020-03-12 16:57 ` Segher Boessenkool
2020-03-12 23:36 ` Alan Modra
2020-03-13 15:40 ` Segher Boessenkool
2020-03-13 23:00 ` Alan Modra [this message]
2020-03-18 21:53 ` Segher Boessenkool
2020-03-23 1:51 ` [RS6000] PR94145, " Alan Modra
2020-03-26 17:12 ` Segher Boessenkool
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=20200313230002.GB23597@bubble.grove.modra.org \
--to=amodra@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--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).