Consider: struct flags { unsigned f0 : 1; unsigned f1 : 1; };
_Bool foo (struct flags *p) { if (p->f0) return 1; return p->f1; } With "cc1 -O2 -fomit-frame-pointer", I get foo: movl 4(%esp), %eax movb (%eax), %dl movb %dl, %al andl $1, %eax testb %al, %al jne .L7 xorl %eax, %eax testb $2, %dl setne %al ret .p2align 2,,3 .L7: movl $1, %eax ret Note that andl and testb are not combined to "testb $1, %al". If they were combined, we would not destroy %eax, so we would not need to make a copy of %al for a later use. With -march=pentium4 or -march=athlon-xp, I get a similar result. -- Summary: andl and testb are not combined 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=17931