Consider:

struct flags {
  unsigned f0 : 1;
};

_Bool
bar (struct flags *p, struct flags *q)
{
  return (!p->f0 && !q->f0);
}

With "cc1 -O2 -fomit-frame-pointer -march=i386", I get

bar:
        movl    4(%esp), %eax
        testb   $1, (%eax)
        jne     .L9
        movl    8(%esp), %eax
        testb   $1, (%eax)
        sete    %al
        movzbl  %al, %eax
        movzbl  %al, %eax
        ret
        .p2align 2,,3
.L9:
        xorl    %eax, %eax
        movzbl  %al, %eax
        ret

Note the two consecutive movzbl.  We don't need the second one.

Also note the xorl followed by movzbl.  We don't need the movzbl.

-- 
           Summary: Two consecutive movzbl are generated
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: enhancement
          Priority: P2
         Component: rtl-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
GCC target triplet: i686-pc-linux-gnu


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

Reply via email to