https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91188
--- Comment #2 from Uroš Bizjak <ubizjak at gmail dot com> --- The patched gcc compiles to: test_andb: movl %edi, %eax # 2 [c=4 l=2] *movsi_internal/0 andb %sil, %al # 9 [c=4 l=3] *andqi_1_slp ret # 23 [c=0 l=1] simple_return_internal The patch also handles memory: --cut here-- struct S1 { unsigned char val; unsigned char pad1; unsigned short pad2; }; unsigned char m; struct S1 __attribute__((noinline)) test_andb (struct S1 a) { a.val &= m; return a; } --cut here-- gcc -O2: test_andb: movl %edi, %eax # 2 [c=4 l=2] *movsi_internal/0 andb m(%rip), %al # 7 [c=8 l=6] *andqi_1_slp ret # 20 [c=0 l=1] simple_return_internal and immediate operands: --cut here-- struct S1 { unsigned char val; unsigned char pad1; unsigned short pad2; }; struct S1 __attribute__((noinline)) test_andb (struct S1 a) { a.val &= 0x2a; return a; } --cut here-- gcc -O2: test_andb: movl %edi, %eax # 2 [c=4 l=2] *movsi_internal/0 andb $42, %al # 7 [c=4 l=2] *andqi_1_slp ret # 20 [c=0 l=1] simple_return_internal