This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Is it safe to use _Bool as asm statement outputs on x86?
- From: "H. Peter Anvin" <hpa at zytor dot com>
- To: Richard Henderson <rth at redhat dot com>, "H.J. Lu" <hjl dot tools at gmail dot com>, GCC Development <gcc at gcc dot gnu dot org>
- Date: Tue, 02 Jun 2015 23:15:46 -0700
- Subject: Re: Is it safe to use _Bool as asm statement outputs on x86?
- Authentication-results: sourceware.org; auth=none
- References: <556E4067 dot 3090905 at zytor dot com> <556E5229 dot 4010809 at redhat dot com>
On 06/02/2015 06:02 PM, Richard Henderson wrote:
> On 06/02/2015 04:46 PM, H. Peter Anvin wrote:
>> For the x86 backend explicitly, is doing something like:
>>
>> _Bool x;
>>
>> asm("blah ; setc %0" : "=qm" (x));
>>
>> ... guaranteed to be safe for older versions of gcc?
>
> I believe so, for the restricted set of conditions I expect you're asking.
> In particular:
>
> (1) Linux has always defined _Bool as a byte (indeed, afaik only Darwin
> has ever done otherwise).
>
> (2) You must really produce 0/1 from the asm; the compiler doesn't re-do
> the canonicalization afterward, and afaik we do rely on that in the
> optimizers. But certainly that's true for any version of GCC.
>
That is all good as far as I am concerned.
-hpa