This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: __attribute__((naked) on x86 would be useful


Jakub Jelinek wrote:
> > what I'd like to be two instructions:
> > 
> >         addl $16,4(%esp)
> >         jmp bar
> > 
> > into seven:
>
> -O2 -fomit-frame-pointer compiles this into
>         movl    4(%esp), %eax
>         addl    $16, %eax
>         movl    %eax, 4(%esp)
>         jmp     bar
> on both gcc-3_3-rhl-branch and gcc-3_4-branch.

That's a nice improveent.  GCC 3.2.2 generates 12 instructions because
-fomit-frame-pointer disables the tail call.

> > Interestingly, that movl/addl/movl in the middle there could just as
> > well be one instruction.
> 
> Why?  You are not optimizing for space, and the 3 insns are faster I think
> (contemporary IA-32 CPUs prefer simple instructions).

With -Os it still emits 3 insns (GCC 3.2.2).

-- Jamie


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]