Attached is a simplified test case from dalvik VM. Compile it with options -march=armv7-a -mthumb -Os -finline-functions, gcc generates
Dalvik_sun_misc_Unsafe_getObject: push {r0, r1, r2, r4, r5, lr} ldr r5, [r0, #4] mov r4, r1 movs r2, #8 add r1, r0, #8 mov r0, sp bl memcpy ldr r3, [sp, #0] ldr r3, [r5, r3] str r3, [r4, #0] pop {r1, r2, r3, r4, r5, pc} If we inline memcpy, the result can be LDRD r2,r0,[r0,#4] LDR r0,[r2,r0] STR r0,[r1,#0] BX lr There are at least 2 problems prevent it to be inlined for target arm. 1. In function emit_block_move_hints, for some unknown reason, the alignment is wrongly computed as 8 bits. 2. The MOVE_RATIO defined in arm.h is too small. #define MOVE_RATIO(speed) (arm_tune_xscale ? 4 : 2) It means only when we move 1 unit of memory, then the memcpy can get a chance to be inlined. -- Summary: gcc failed to inline memcpy 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=43814