public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Michael Meissner <meissner@linux.vnet.ibm.com>
To: Richard Guenther <richard.guenther@gmail.com>
Cc: Michael Meissner <meissner@linux.vnet.ibm.com>,
	gcc-patches@gcc.gnu.org,        dje.gcc@gmail.com
Subject: Re: [PATCH] Add -mno-r11 option to suppress load of ppc64 static chain in indirect calls
Date: Thu, 07 Jul 2011 16:14:00 -0000	[thread overview]
Message-ID: <20110707161340.GA4442@hungry-tiger.westford.ibm.com> (raw)
In-Reply-To: <CAFiYyc1BsKpw0G=i4eTSKouEDNz+LpT1SNMprL6hoo23P5Wi3Q@mail.gmail.com>

On Thu, Jul 07, 2011 at 05:53:09PM +0200, Richard Guenther wrote:
> Well, I guess you don't propose to build glibc with -mno-r11?  The compiler
> certainly can't figure out in _all_ cases - but it should be able to handle
> most of the cases (with LTO even more cases) ok, no?

No, we are no proposing to build glibc or any standard library with -mno-r11.

> I also wonder why loading a register is so expensive compared to the
> actual call ...

We are trying to eliminate instructions in the indirect function call pathway,
and this happens to be the first and easiest.  As I said, I see a 5-7% gain in
h264ref, but a 2-3% drop in mcf.  In addition to saving of not loading r11,
perhaps more of the gain comes from not saving the TOC (r2) at the point of the
call, but moving it into the prologue for functions that don't call alloca,
setjmp, or have exceptions.  This is because the instruction sequence before
the change was:

	ld r0,0(<ptr>)		/* load function address */
	mtctr r0		/* move to ctr register */
	st r2,40(r1)		/* save TOC value */
	ld r2,8(<ptr>)		/* load new TOC value */
	ld r11,16(<ptr>)	/* load static chain */
	bctrl			/* call function */
	ld r2,40(r1)		/* reload our TOC */

The ld of r2 has to wait for the store queue to drain in some cases, because it
is loading a value being stored.


> > I certainly can call the switch -mno-static-chain, which is perhaps more
> > meaningful (at least to us compiler folk, I'm not sure static chain means much
> > to the normal programmer).
> 
> Well, that's up to the target maintainers to decide, maybe
> -mno-nested-functions instead?

David?

-- 
Michael Meissner, IBM
5 Technology Place Drive, M/S 2757, Westford, MA 01886-3141, USA
meissner@linux.vnet.ibm.com	fax +1 (978) 399-6899

  reply	other threads:[~2011-07-07 16:14 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-06 22:39 Michael Meissner
2011-07-06 23:05 ` David Edelsohn
2011-07-06 23:57   ` [PATCH] Update html docs for -mno-r11 and --param case-value-threshold Michael Meissner
2011-10-30  8:16     ` Gerald Pfeifer
2011-07-07  9:01 ` [PATCH] Add -mno-r11 option to suppress load of ppc64 static chain in indirect calls Richard Guenther
2011-07-07  9:06   ` Jakub Jelinek
2011-07-07  9:17     ` Richard Guenther
2011-07-07 15:50   ` Michael Meissner
2011-07-07 15:55     ` Richard Guenther
2011-07-07 16:14       ` Michael Meissner [this message]
2011-07-07 16:15       ` Tristan Gingold
2011-07-07 19:24       ` David Edelsohn
2011-07-07 20:22         ` Richard Guenther
2011-07-11 15:28           ` David Edelsohn
2011-07-13 22:03         ` Michael Meissner

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=20110707161340.GA4442@hungry-tiger.westford.ibm.com \
    --to=meissner@linux.vnet.ibm.com \
    --cc=dje.gcc@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=richard.guenther@gmail.com \
    /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).