From: Richard Guenther <richard.guenther@gmail.com>
To: Michael Matz <matz@suse.de>
Cc: Georg-Johann Lay <avr@gjlay.de>,
Ulrich Weigand <uweigand@de.ibm.com>,
Ian Lance Taylor <iant@google.com>,
Mikael Pettersson <mikpe@it.uu.se>,
Michael Walle <michael@walle.cc>,
Hans-Peter Nilsson <hp@bitrange.com>,
Richard Henderson <rth@redhat.com>,
gcc@gcc.gnu.org
Subject: Re: libgcc: strange optimization
Date: Wed, 03 Aug 2011 14:02:00 -0000 [thread overview]
Message-ID: <CAFiYyc169wDA--H-WkZsKGh5LToUANKJDQG_gXi7+7+2q_VnGw@mail.gmail.com> (raw)
In-Reply-To: <Pine.LNX.4.64.1108031517260.26760@wotan.suse.de>
On Wed, Aug 3, 2011 at 3:27 PM, Michael Matz <matz@suse.de> wrote:
> Hi,
>
> On Wed, 3 Aug 2011, Richard Guenther wrote:
>
>> > Yes, that's reasonable. As I understand the docs, in code like
>> >
>> > void foo ()
>> > {
>> > register int var asm ("r1") = 10;
>> > asm (";; use r1");
>> > }
>> >
>> > there is nothing that connects var to the asm and assuming that
>> > r1 holds 10 in the asm is a user error.
>> >
>> > The only place where the asm attached to a variable needs to have
>> > effect are the inline asm sequences that explicitly refer to
>> > respective variables. If there is no inline asm referencing a
>> > local register variable, there is on difference to a non-register
>> > auto variable; there could even be a warning that in such a case
>> > that
>> >
>> > register int var asm ("r1") = 10;
>> >
>> > is equivalent to
>> >
>> > int var = 10;
>> >
>> > This would render local register variables even more functional
>> > because no one needed to care if there were implicit library calls or
>> > things like that.
>>
>> Yes, I like that idea.
>
> I do too. Except it doesn't work :)
>
> There's a common idiom of accessing registers read-only by declaring local
> register vars. E.g. to (*grasp*) the stack pointer. There won't be a DEF
> for that register var, and hence at use-points we couldn't reload any
> sensible values into those registers (and we really shouldn't clobber the
> stack pointer in this way).
>
> We could introduce that special semantic only for non-reserved registers,
> and require no writes to register vars for reserved registers.
>
> Or we could simply do:
>
> if (any_local_reg_vars)
> optimize = 0;
>
> But I already see people wanting to _do_ optimization also with local reg
> vars, "just not the wrong optimizations" ;-/
I'd say we should start rejecting all these bogus constructs by default
(maybe accepting them with -fpermissive and then, well, maybe generate
some dwim code). That is, local register var decls are only valid
with an initializer, they are implicitly constant (you can't re-assign to them).
Reserved registers are a no-go (like %esp), either global or local.
Richard.
>
> Ciao,
> Michael.
next prev parent reply other threads:[~2011-08-03 14:02 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-01 20:30 Michael Walle
2011-08-01 20:51 ` Georg-Johann Lay
2011-08-01 21:14 ` Michael Walle
2011-08-02 6:47 ` Georg-Johann Lay
2011-08-02 6:29 ` Hans-Peter Nilsson
2011-08-01 21:30 ` Richard Henderson
2011-08-02 6:37 ` Hans-Peter Nilsson
2011-08-02 8:49 ` Mikael Pettersson
2011-08-02 9:47 ` Richard Guenther
2011-08-02 10:02 ` Georg-Johann Lay
2011-08-02 10:11 ` Richard Guenther
2011-08-02 10:55 ` Michael Walle
2011-08-02 12:06 ` Mikael Pettersson
2011-08-02 12:23 ` Richard Guenther
2011-08-02 12:36 ` Georg-Johann Lay
2011-08-02 12:54 ` Hans-Peter Nilsson
2011-08-02 13:09 ` Richard Guenther
2011-08-02 13:16 ` Hans-Peter Nilsson
2011-08-03 4:59 ` Miles Bader
2011-08-02 13:23 ` Ian Lance Taylor
2011-08-02 13:42 ` Richard Guenther
2011-08-02 14:35 ` Ian Lance Taylor
2011-08-03 9:12 ` Ulrich Weigand
2011-08-03 9:51 ` Georg-Johann Lay
2011-08-03 10:04 ` Richard Guenther
2011-08-03 13:27 ` Michael Matz
2011-08-03 14:02 ` Richard Guenther [this message]
2011-08-03 14:55 ` Georg-Johann Lay
2011-08-03 15:05 ` Richard Henderson
2011-08-04 0:20 ` Hans-Peter Nilsson
2011-08-04 7:29 ` Andreas Schwab
2011-08-04 13:04 ` Hans-Peter Nilsson
2011-08-04 9:51 ` Andrew Haley
2011-08-04 9:52 ` Richard Guenther
2011-08-04 11:11 ` Andrew Haley
2011-08-04 11:20 ` Richard Guenther
2011-08-04 14:46 ` Andrew Haley
2011-08-06 15:00 ` Paolo Bonzini
2011-08-08 8:06 ` Richard Guenther
2011-08-08 10:59 ` Paolo Bonzini
2011-08-02 16:03 ` Richard Henderson
2011-08-02 20:10 ` Richard Guenther
2011-08-02 17:21 ` Georg-Johann Lay
2011-08-09 16:55 ` Richard Earnshaw
2011-08-09 17:24 ` Ulrich Weigand
2011-08-09 19:48 ` Hans-Peter Nilsson
2011-08-10 0:40 ` Hans-Peter Nilsson
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=CAFiYyc169wDA--H-WkZsKGh5LToUANKJDQG_gXi7+7+2q_VnGw@mail.gmail.com \
--to=richard.guenther@gmail.com \
--cc=avr@gjlay.de \
--cc=gcc@gcc.gnu.org \
--cc=hp@bitrange.com \
--cc=iant@google.com \
--cc=matz@suse.de \
--cc=michael@walle.cc \
--cc=mikpe@it.uu.se \
--cc=rth@redhat.com \
--cc=uweigand@de.ibm.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).