reduced testcase: typedef struct { unsigned char b1, b2; } __attribute__((aligned(8))) S; void f( S const* s, unsigned char* b1, unsigned char* b2 ) { *b1 = s->b1; *b2 = s->b2; }
generates at -Os and -O3: f: movb (%rdi), %al # <variable>.b1, <variable>.b1 movb %al, (%rsi) # <variable>.b1,* b1 movb 1(%rdi), %al # <variable>.b2, <variable>.b2 movb %al, (%rdx) # <variable>.b2,* b2 ret gcc could (at least at -Os) reduce code size and memory accesses to: movw (%rdi), %ax movb %al, (%rsi) # <variable>.b1,* b1 movb %ah, (%rdx) # <variable>.b2,* b2 ret -- Summary: missed 'movw' optimization. Product: gcc Version: 4.4.3 Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: target AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: pluto at agmk dot net GCC build triplet: x86_64-gnu-linux GCC host triplet: x86_64-gnu-linux GCC target triplet: x86_64-gnu-linux http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43311