gcc return struct code generation
Ian Lance Taylor
iant@google.com
Tue Aug 30 17:45:00 GMT 2011
jose gomez valcarcel <jcgv33@yahoo.es> writes:
> For curiosity, today i test this code with the intel compiler (12.0.5.220). It generates this code for fn:
>
> icc -O2 -fomit-frame-pointer -c z.c
>
>
> 0000000000000000 <fn>:
> 0:56 push %rsi
> 1:e8 00 00 00 00 callq 6 <fn+0x6>
> 6:48 03 c2 add %rdx,%rax
> 9:59 pop %rcx
> a:c3 retq
>
> Yo can see the code changes the values of registers RSI and RCX with apparently no reason ! (appart of computing correctly the c code of fn).
> Also this code uses stack with apparently no reason, or i can not see it.
The stack has to be aligned at a 16-byte boundary before the function
call. The function call itself pushes 8 bytes onto the stack. So
another 8 byte adjustment is required before making another function
call. icc is choosing to do that adjustment using push and pop. I
don't know why that is preferable to adding and subtracting a constant,
but there may well be a reason.
Ian
More information about the Gcc-help
mailing list