Compile following code with options -march=armv7-a -mthumb -Os char* tq(char* p, char c1, char c2) { *p++ = c1; *p++ = c2; return p; }
GCC 4.6 generates strb r1, [r0, #0] strb r2, [r0, #1] adds r0, r0, #2 bx lr It can be simplified to: strb r2, [r0, #1] strb r1, [r0], #2 bx lr If I change the option -Os to -O2, the result is worse: mov r3, r0 adds r0, r0, #2 strb r1, [r3, #0] strb r2, [r3, #1] bx lr -- Summary: memory access and address update in one instruction for thumb2 Product: gcc Version: 4.6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target 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=45039