This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: ptr vs ref performance??
- To: gcc at gcc dot gnu dot org, rob at e-critical dot com
- Subject: Re: ptr vs ref performance??
- From: Mike Stump <mrs at windriver dot com>
- Date: Thu, 14 Dec 2000 17:27:30 -0800 (PST)
> Date: Thu, 14 Dec 2000 16:36:13 -0800
> From: Rob Willis <rob@e-critical.com>
> It appears as if using a reference variable is faster than
> de-referencing from a pointer.
Cool! :-)
> ptr de-ref:
> value = *tp;
> ref access;
> value = tr;
> Can anyone explain why this is?
It seems like you'll want to team up with someone that can run gcc -da
-S on the testcases, and analyze and report this type of stuff... Or,
if you're feeling really adventuresome you could try your hand at it.
Usually, one can get it down to the pass in the optimizer that is
failing to do the best thing with the given rtl, and then you step
into the compiler with the debugger and find out why...
I tried the implied testcase and got exactly identical code:
long value = 0;
long test = 5213;
long & tr( test );
long * tp = &test;
int main1() {
value = *tp;
}
int main2() {
value = tr;
}
When asking these sorts of questions, it is important to include a
testcase. Not an idea for one, but a real one.