Compile the attached test case with options -Os -mthumb, gcc generates: add r1, r1, #40 mov r3, r0 ldrb r2, [r1] add r3, r3, #40 strb r2, [r3] @ sp needed for prologue bx lr
When change the options to -O2 -mthumb, gcc generates: mov r3, #40 ldrb r2, [r1, r3] strb r2, [r0, r3] @ sp needed for prologue bx lr It is both smaller and faster. Compare the dumped IL with different options, all TREE expressions are identical. The first difference occurs after rtl expanding. -- Summary: [missed optimization] inefficient byte access when -Os is specified Product: gcc Version: 4.5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: rtl-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: carrot at google dot com GCC build triplet: i686-linux GCC host triplet: i686-linux GCC target triplet: arm-eabi http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42226