struct B {
  unsigned bit : 1;
};

void
ior (struct B *b)
{
  b->bit |= 1;
}

I get:

ior (b)
{
<bb 0>:
  b->bit = (<unnamed type>) (unsigned char) ((signed char) b->bit | 1);
  return;

}

Note that we could just say b->bit = 1;

-- 
           Summary: OR of a bitfield and a constant is not optimized at tree
                    level
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: enhancement
          Priority: P2
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: kazu at cs dot umass dot edu
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18031

Reply via email to