There is no reason to be moving %esp in this function. $ cat cc.c typedef unsigned long size_t; extern void *memcpy (void *__restrict, const void *__restrict, size_t); char *foo1(char*buf){ short tmp2; int tmp4; *buf++ = 42; tmp2=0xfeed; memcpy(buf,&tmp2,2); buf += 2; tmp4 = 0x12345678; memcpy(buf,&tmp4,4); buf += 4; tmp4 = 0x12345678; memcpy(buf,&tmp4,4); buf += 4; return buf; } $ gcc -m32 -fomit-frame-pointer -mregparm=3 -O2 -S cc.c $ cat cc.s .file "cc.c" .text .p2align 4,,15 .globl foo1 .type foo1, @function foo1: subl $16, %esp movb $42, (%eax) movw $-275, 1(%eax) movl $305419896, 3(%eax) movl $305419896, 7(%eax) addl $11, %eax addl $16, %esp ret .size foo1, .-foo1 .ident "GCC: (GNU) 4.1.1 20060828 (Red Hat 4.1.1-20)" .section .note.GNU-stack,"",@progbits $
-- Summary: useless stack movement Product: gcc Version: 4.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: acahalan at gmail dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30026