GCC 4.9 generates bigger code for x86

David Guillen Fandos david@davidgf.es
Thu Oct 9 19:08:00 GMT 2014


Hi all,

I just noticed that 4.9 generates some code overhead for 386 machines 
respect to 4.8.
In my test case I used 4.8.1 and 4.9.1 and realized that when compiling 
with "-Os -fno-exceptions -fno-align-functions -fomit-frame-pointer" 
certain things change:

On 4.9 the backend adds some "nop" after ret or jmp.
It also stops using "leave" instruction, which is really convenient to 
save some instructions.

It think it is not using leave because of register allocation. In 4.8 a 
function starts like this:

      390:    55                       push   %ebp
      391:    89 e5                    mov    %esp,%ebp
      393:    53                       push   %ebx

Whereas in 4.9 it starts:

      386:    53                       push   %ebx
      387:    89 cb                    mov    %ecx,%ebx
      389:    83 ec 28                 sub    $0x28,%esp

So the first function actually saves some space.

Any ideas, thoughts, comments?

Thanks a lot,
David G.F.



More information about the Gcc mailing list