This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: PowerPC function prologue/epilogue not optimised away as expected
- From: Ian Lance Taylor <iant at google dot com>
- To: rdiezmail-gcc at yahoo dot de
- Cc: gcc-help at gcc dot gnu dot org
- Date: Tue, 28 Jun 2011 09:45:39 -0700
- Subject: Re: PowerPC function prologue/epilogue not optimised away as expected
- References: <1309249135.65514.YahooMailClassic@web25404.mail.ukl.yahoo.com>
"R. Diez" <rdiezmail-gcc@yahoo.de> writes:
> Equivalent code generated by an old commercial compiler (with my own comments added). It's basically the same, only with the function prologue and epilogue optimised away:
>
> 000f8e3c <UartWrite>:
> ; clrlwi rA,rS,16 (equivalent to rlwinm rA,rS,0,16,31)
> ; Clear the high-order 16 bits of rS and place the result into rA.
> f8e3c: 54 84 04 3e clrlwi r4,r4,16
>
> f8e40: 48 00 62 a0 b ff0e0 <SMC2Write>
This is a tailcall: the function call has been converted into a jump.
> I found this message from Ian Lance Taylor about not being able to optimise tail calls:
>
> http://gcc.gnu.org/ml/gcc-help/2010-05/msg00257.html
> "It's a known limitation due to the way the PowerPC EABI works. Tailcalls are only possible to static functions."
>
> However, that message offers no explanation and I'm not sure whether the underlying reason also applies here.
Yes and no. All released versions of gcc will refuse to implement the
tailcall optimization here. However, this restriction is not required
in all cases. For EABI, tailcalls are not permitted when passing more
vector parameters than the caller itself accepts, or when using -fpic
-msecure-plt. I think that the current development version of gcc
actually will do a tailcall here. The patch was:
http://gcc.gnu.org/ml/gcc-patches/2011-04/msg00674.html
Ian