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]

Re: penalty for member functions?


> I append the code below.

Very interesting. I find that there is a significant variation across
compiler versions. Leaving the optimization constant (-O2), I get

2.95.1:
flat loop 4.010
Foo::loop 3.740

2.95.2:
flat loop 4.010
Foo::loop 4.030

2.96 19991121 (experimental)
flat loop 4.300
Foo::loop 3.730

So, in no case I can observe that the method is slower than the
function. If anything, it is faster.

Comparing the assembler code in the 2.96 code, I find they are
*identical* with two exceptions:

- when the flat loop accesses a global variable (egdes), the method
  goes through 'this'
- the entry and exit code is slightly different

I have not analysed this further.

Regards,
Martin

P.S. All of this was on
processor	: 0
vendor_id	: AuthenticAMD
cpu family	: 5
model		: 8
model name	: AMD-K6(tm) 3D processor
stepping	: 12
cpu MHz		: 350.800525
with Linux 2.2.5, glibc 2.1


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