This is the mail archive of the gcc-help@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]

Tail call optimization on PowerPC


Hello.

I have a question about tail call optimization and whether it is performed
when compiling code for the PowerPC architecture. When compiling the same
simple test program for the x86 and MIPS architectures, inspecting the
assembly code shows that tail call optimization is performed, and it can
also be turned off using -fno-optimize-sibling-calls (I'm using plain -O2
otherwise). 

However, for PowerPC no tail call optimization is present in the assembly
code, and it makes no difference whether I use the
-fno-optimize-sibling-calls flag or not. So my question is: is this a known
limitation, a bug, or am I simply doing something wrong?

Here's the test program I'm using in case it is of interest (plain C):

---

int (*fn_ptr)(int);
extern int fn(int x);

int
simple(int x)
{
   return fn(x);
}

int
ptr(int x)
{
   return fn_ptr(x);
}

int
main(int argc, const char *argv[])
{
   fn_ptr = &fn;
   return simple(argc) + ptr(argc);
}

---

I'm using GCC 4.4.3 built as a cross-compiler for powerpc-eabi and compiling
on a 32 bit linux.

Best regards,
Robin


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