When compiling the following program with -Os, the short member x of struct a is read using a movl instruction instead of movzwl.
struct a { int dummy; short x; }; struct b { unsigned short x; }; extern void dummy(struct b *b); void f(struct a *a, struct b *b) { dummy(b); if (a) { asm("/* THIS FIELD IS ONLY 16 BITS */"); b->x = a->x; } } With -O3: movzwl 4(%ebx), %eax movw %ax, (%esi) And -Os: movl 4(%ebx), %eax movw %ax, (%esi) -- Summary: -Os produces 32-bit load from 16-bit variable Product: gcc Version: 4.1.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: vegard at peltkore dot net GCC build triplet: i386-redhat-linux GCC host triplet: i386-redhat-linux GCC target triplet: i386-redhat-linux http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34161