This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Improve folding of bitwise ops on booleans
- From: Kai Tietz <ktietz70 at googlemail dot com>
- To: Jeff Law <law at redhat dot com>
- Cc: Richard Biener <richard dot guenther at gmail dot com>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 5 Jun 2013 18:57:46 +0200
- Subject: Re: [PATCH] Improve folding of bitwise ops on booleans
- References: <51A90588 dot 5080807 at redhat dot com> <CAFiYyc3yxAs0vV8qS830ubnprJSs5o4RCD+S9Pzkink_VPRzGw at mail dot gmail dot com> <CAEwic4bhcDbNHETQn5gWPZNHF35auSK9nWJ0mhvkP3OjzeY7SQ at mail dot gmail dot com> <51AE3DFD dot 1010700 at redhat dot com>
2013/6/4 Jeff Law <law@redhat.com>:
> On 06/03/2013 08:23 AM, Kai Tietz wrote:
>>
>>
>> Btw there is one optimization in this context which might be something
>> worth here too.
>> -X -> X for 1-bit typed X (signed doesn't matter here).
>
> I've had a hell of a time trying to trigger a case where this isn't already
> handled. Samples welcome.
A sample for this is
typedef struct onebit {
unsigned int i : 1;
} onebit;
_Bool boo (onebit a, onebit b, onebit c)
{
onebit i1, i2;
i1.i = a.i + b.i;
i2.i = a.i + c.i;
i1.i -= i2.i;
i1.i -= b.i;
return i1.i;
}
Kai