This is the mail archive of the
mailing list for the GCC project.
Re: gcc torture test pr52286.c
- From: Jeff Law <law at redhat dot com>
- To: Michael Matz <matz at suse dot de>
- Cc: pshortis at dataworx dot com dot au, "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>
- Date: Mon, 28 Aug 2017 11:40:27 -0600
- Subject: Re: gcc torture test pr52286.c
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=law at redhat dot com
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 79F1E80480
- References: <59A38EFD.email@example.com> <firstname.lastname@example.org> <alpine.LSU.email@example.com>
On 08/28/2017 11:33 AM, Michael Matz wrote:
> On Mon, 28 Aug 2017, Jeff Law wrote:
>>> long a, b = 0;
>>> asm ("" : "=r" (a) : "0" (0));
>> I wouldn't use a matching constraint here. Something like this is
>> probably closer to what you want:
>> asm ("" : "=r" (a) : "n" (0));
>> The "n" says accept any immediate integer constant with a compile time
>> known value.
>> In fact, I could probably argue that "0" (0) should generate an error as
>> a constraint -- it's meaningless in that you can't match a constant
>> integer input to any output.
> Huh? No. The semantics are perfectly valid for this. It says "put the
> output into a register, place that into variable 'a', put the input value
> into the same register". Value is just that, an arbitrary rvalue (of
> correct type of course). We accept any expression forms, as we should,
> including constants.
I can't remember matching constraints ever working that way.
REgister allocation and reloading will first try to allocate the two
objects to the same register and if that doesn't work it will emit
copies to ensure they are the same register.
But that doesn't work when one of the objects isn't a register. There's
no allocno for the constant. It's just that, a constant.
> FWIW, the above is a "portable" way to get the value 0 into 'a' without
> the compiler knowing.
?!? Mine is just as portable and should actually work :-)