This is the mail archive of the gcc-patches@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: [LTO] Fix C++ thunks


Chris Lattner wrote:

>> 1. Although we've never implemented it, one of the ideas with thunks was
>> that you could fall through into the main function body, rather than
>> jump to it.  That avoids a costly, often mis-predicted branch.  So, we
>> shouldn't do anything that makes that harder.
> 
> When are these branches expensive?  My understanding is that all
> reasonable desktop hardware (at least) has "perfect" prediction for
> unconditional branches.

Three reasons:

1. non-desktop hardware

2. even perfectly predicted branches are not free

3. thunks are generally the target of indirect jumps through a vtable,
so you have a sequence like "load memory to register", "indirect jump
through register", "add constant to register", "jump".  There's a lot of
hardware that doesn't do a great job with predicting all of that; if you
don't work out the target of the indirect jump, you don't have time to
load the target of the final jump before you hit it.

-- 
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713


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