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: Optimized program four times slower.


"Sebastien M." <ploouuf@yahoo.fr> wrote:
>
> I have a strange behaviour when I compile my program with -O2: it becomes slower

It isn't rare.  The only way to find out for sure is to print the
assembler, work out EXACTLY where everything is located and check
it all carefully.  You need to know a lot about computer architecture
to do the analysis, too.

Generally, it is due to a cache problem or similar.  The alignment
changes, and one of the codes has to reload a couple of locations
each time round the loop.  You can often make this phenomenon go
away (or appear!) by adding a completely irrelevant statement
elsewhere in the code.


Regards,
Nick Maclaren,
University of Cambridge Computing Service,
New Museums Site, Pembroke Street, Cambridge CB2 3QH, England.
Email:  nmm1@cam.ac.uk
Tel.:  +44 1223 334761    Fax:  +44 1223 334679


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