This is the mail archive of the
mailing list for the GCC project.
Re: Question regarding constraint usage within inline asm
- From: Alan Modra <amodra at gmail dot com>
- To: Peter Bergner <bergner at linux dot ibm dot com>
- Cc: GCC <gcc at gcc dot gnu dot org>
- Date: Wed, 20 Feb 2019 13:39:59 +1030
- Subject: Re: Question regarding constraint usage within inline asm
- References: <firstname.lastname@example.org>
On Mon, Feb 18, 2019 at 01:13:31PM -0600, Peter Bergner wrote:
> I have a question about constraint usage in inline asm when we have
> an early clobber output operand. The test case is from PR89313 and
> looks like the code below (I'm using "r3" for the reg on ppc, but
> you could also use "rax" on x86_64, etc.).
> long input;
> 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".
> Clearly, we cannot assign
> a register to the "input" variable that is both the same and different
> to the register that is assigned to "output".
No, you certainly can do that. I think you have found a bug in lra.
Australia Development Lab, IBM