public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Alan Modra <amodra@gmail.com>
To: Peter Bergner <bergner@linux.ibm.com>
Cc: GCC <gcc@gcc.gnu.org>
Subject: Re: Question regarding constraint usage within inline asm
Date: Wed, 20 Feb 2019 22:04:00 -0000	[thread overview]
Message-ID: <20190220220437.GC23427@bubble.grove.modra.org> (raw)
In-Reply-To: <61bb9a58-0d4c-70e9-7611-3169de0c8950@linux.ibm.com>

On Wed, Feb 20, 2019 at 10:08:07AM -0600, Peter Bergner wrote:
> On 2/19/19 9:09 PM, Alan Modra wrote:
> > On Mon, Feb 18, 2019 at 01:13:31PM -0600, Peter Bergner wrote:
> >> long input;
> >> long
> >> bug (void)
> >> {
> >>   register long output asm ("r3");
> >>   asm ("blah %0, %1, %2" : "=&r" (output) : "r" (input), "0" (input));
> >>   return output;
> >> }
> >>
> >> I know an input operand can have a matching constraint associated with
> >> an early clobber operand, as there seems to be code that explicitly
> >> mentions this scenario.  In this case, the user has to manually ensure
> >> that the input operand is not clobbered by the early clobber operand.
> >> In the case that the input operand uses an "r" constraint, we just
> >> ensure that the early clobber operand and the input operand are assigned
> >> different registers.  My question is, what about the case above where
> >> we have the same variable being used for two different inputs with
> >> constraints that seem to be incompatible?
> > 
> > Without the asm("r3") gcc will provide your "blah" instruction with
> > one register for %0 and %2, and another register for %1.  Both
> > registers will be initialised with the value of "input".
> 
> That's not what I'm seeing.  I see one pseudo (123) used for the output
> operand and one pseudo (121) used for both input operands.  Like so:

I meant by the time you get to assembly.

	blah 3, 9, 3

> That said, talking with Segher and Uli offline, they both think the
> inline asm usage in the test case should be legal

Good, it seems we are in agreement.  Incidentally, the single pseudo
for the inputs happens even for testcases like

long input;
long
bug (void)
{
  register long output /* asm ("r3") */;
  asm ("blah %0, %1, %2" : "=r" (output) : "wi" (input), "0" (input));
  return output;
}

-- 
Alan Modra
Australia Development Lab, IBM

  parent reply	other threads:[~2019-02-20 22:04 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-18 19:14 Peter Bergner
2019-02-20  3:10 ` Alan Modra
2019-02-20 16:08   ` Peter Bergner
2019-02-20 19:24     ` Segher Boessenkool
2019-02-20 22:04     ` Alan Modra [this message]
2019-02-20 22:19       ` Alan Modra
2019-02-21  2:57         ` Peter Bergner
2019-02-21  3:40           ` Alan Modra
2019-02-21 23:16             ` Peter Bergner
2019-02-22  1:08               ` Segher Boessenkool
2019-02-25 18:32                 ` Michael Matz
2019-02-28  4:16                   ` Segher Boessenkool
2019-02-28 13:01                     ` Michael Matz
2019-02-21  3:03       ` Peter Bergner

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=20190220220437.GC23427@bubble.grove.modra.org \
    --to=amodra@gmail.com \
    --cc=bergner@linux.ibm.com \
    --cc=gcc@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).