This is the mail archive of the gcc-help@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: Confusing optimization


"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


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