This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Improve folding of bitwise ops on booleans


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]