[Bug optimization/15256] New: [tree-ssa] Optimize manual bitfield manipilation.

kazu at cs dot umass dot edu gcc-bugzilla@gcc.gnu.org
Mon May 3 08:03:00 GMT 2004

It would be nice if we can convert foo into bar.

unsigned int
foo (unsigned int eax)
  unsigned int edx = eax & 1;
  edx ^= 1;
  eax &= -2;
  eax |= edx;
  return eax;

unsigned int
bar (unsigned int eax)
  return eax ^ 1;

The last SSA form looks like:

foo (eax)
  unsigned int edx;

<bb 0>:
  edx_2 = eax_1 & 1;
  edx_3 = edx_2 ^ 1;
  eax_4 = eax_1 & 0fffffffe;
  eax_5 = eax_4 | edx_3;
  return eax_5;


This testcase is inspired by


This sequence of four instructions is a little too tough for the combiner to
chew as it only considers three insturctions at one time.

Note that some people manually implement bitfields
without relying on ":" in a struct.

           Summary: [tree-ssa] Optimize manual bitfield manipilation.
           Product: gcc
           Version: tree-ssa
            Status: UNCONFIRMED
          Keywords: pessimizes-code
          Severity: enhancement
          Priority: P2
         Component: 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


More information about the Gcc-bugs mailing list