gcl-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gcl-devel] Re: sibling call optimization


From: Jim Wilson
Subject: Re: [Gcl-devel] Re: sibling call optimization
Date: 07 May 2004 18:16:15 -0700

On Fri, 2004-05-07 at 14:39, Camm Maguire wrote:
> OK.  The full cpp output providing a testcase is included below.  I
> will endeavor to file a bugzilla report on it (never done this before)

I took a quick look.

In the -O2 case, LI2 has two functions calls, both of which are
converted to sibcalls.

In the -O3 case, LI2 has two functions calls.  The second one gets
inlined, so now we have 3 function calls, 1 from the original function,
and two from the inlined function.  The call from the original function
gets converted to a sihcall.  The two calls from the inlined function
are not converted to a sibcall because of a technicality.

The code that creates a sibcall only matches a simple pattern, a call
followed by a branch to the prologue.  In the inlined case, the call
sequence has been optimized a bit, to commonize some code, so we end up
with
        call
        branch common_code:
        call
common_code:
        move reg
        branch epilogue
These are both still sibcalls, but the simple pattern matching code in
sibcall.c can't recognize this.

Overall, the -O3 code isn't really much worse than the -O2 code.  In the
O2 code, calling from LI2->LI1->LI2 involves two sibcalls.  In the -O3
case, the same sequence involves one regular function call.  Note that
LI2 is calling itself, not LI1.  This is because LI1 was inlined into
LI2.  So it is possible that the -O3 code may actually be faster, even
though it has calls instead of sibcalls.

Still, we could do even better if we were able to handle these
sibcalls.  I didn't check to see where the inlined calls got optimized. 
It might be possible to avoid this so that we still get the sibcalls
created.  I am unlikely to look into this further.  I'd suggest filing a
bug report if you really care.
-- 
Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com





reply via email to

[Prev in Thread] Current Thread [Next in Thread]