This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Confusing optimization
- From: Ian Lance Taylor <iant at google dot com>
- To: Luca BÃla Palkovics <luca dot bela dot palkovics at gmail dot com>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Sun, 09 May 2010 21:49:36 -0700
- Subject: Re: Confusing optimization
- References: <1273433133.6007.24.camel@luca-laptop>
"Luca BÃla Palkovics" <luca.bela.palkovics@gmail.com> writes:
> Is this normal ? b has nothing todo with a .. why does a get slower ?
> (b is also faster without a...)
There are a number of possibilities. It's hard to know what is
happening without an exact test case. You also neglected to say what
platform you are running on.
Some possibilities are:
1) Measurement error. Surprisingly often people are not measuring
what they think they are measuring, and you didn't provide any
details about how you got your timings.
2) Instruction cache effects, if a() and b() call other functions.
When both are linked together, those other functions will be at
different addresses, and whether they are contiguous may change,
all affecting the instruction cache.
3) Exact aligment of loop starts may shift when both are linked
together, affecting the processor's branch optimizers if it has
any. Similarly, the exact alignment of labels may shift. You can
control these using gcc options like -falign-functions,
-falign-jumps, -falign-labels, -falign-loops.
There are other, less likely, possibilities.
Ian