Confusing optimization

Ian Lance Taylor iant@google.com
Mon May 10 04:49:00 GMT 2010


"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



More information about the Gcc-help mailing list