On Mon, Feb 11, 2013 at 2:02 AM, <sztfg@xxxxxxxxx> wrote: > > For this case: ... > with gcc -c -march=native -O2 sample.c -o sample.o > I got this: ... > As you can see, mov %r8,(%rsp) produse 4 bytes: 4c 89 04 24 and mov %rdi,0x8(%rsp) produces 5 bytes: 48 89 7c 24 08 > push %r8 produces only 2 byte 41 50 and push %rax (or %rcx %rdx ...) produces one byte > You can check other instruction length, for example movq %rax, (%rsp) etc. If your main interest is code size, you should compile with -Os. By default GCC optimizes for runtime performance. When I try -Os GCC builds the array separately and copies it in using rep movsl. Still, you may be right that in this case it would be slightly more efficient to construct the local arrays using push instructions. Unfortunately I suspect that implementing that in GCC's framework would be fairly complex. Currently GCC builds all variables like arrays, that can not be placed in registers on the stack, and initializes them on the stack. Changing the initialization to use push instructions would require reworking those initializations. I doubt cases would arise very often in real program. However, I'm certainly not opposed to it if somebody wants to work on it. Ian