This is the mail archive of the gcc-bugs@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]

[Bug optimization/15310] New: [tree-ssa] Optimize an addition in a bit field


Optimize an addition in a bit field.

struct {
   unsigned int bit0:1;
   unsigned int ubyte:31;
} sdata;

void foo()
{
  sdata.ubyte++;
}

This testcase is inspired by

http://gcc.gnu.org/ml/gcc-patches/2004-05/msg00058.html

Currently, I get:

foo:
        movl    sdata, %eax
        movl    %eax, %edx
        shrl    %edx
        leal    2(%edx,%edx), %edx
        andl    $1, %eax
        orl     %edx, %eax
        movl    %eax, sdata
        ret

We should be able to get

foo:
        addl    $2, sdata
        ret

We might want to lower bit field manipulation at tree level.

-- 
           Summary: [tree-ssa] Optimize an addition in a bit field
           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,roger at eyesopen dot
                    com


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


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