On 23/09/2010 18:09, stefan...@web.de wrote:
Eduardo<nec...@retena.com>  wrote:


Can you try optimize for size? In some cases, it reduces L2 / L3 cache
miss and runs faster than O3. It happens in other compilers and
languages too.

I just tried it: The code gets even slightly larger and much slower (almost a 
factor of 2).

Hi,

Try -Os3 instead of -O3

and try to reorder

type
 TRectangle       =  object
 width   : Integer;
 Area    : Int64;
 NextUnusedRectangle: Integer;

to

type
 TRectangle       =  object
 width   : Integer;
 NextUnusedRectangle: Integer;
 Area    : Int64;

and the var declaration:

 var
 i, MinValley, MinValleyWidth: Integer;
 PrevBar, NextBar            : Integer;
 RectWidth                   : Integer;
 NextBarWidth                : Integer;
 NewEntry, NewEntry2         : Integer;
 MinValleyHeight             : Integer;
 MinValleyArea               : Int64;
 TotalAreaOfFittingRectangles: Int64;
 CurrentRectangle            : Integer;
 PreviousRectangle           : Integer;
 OldFirstUnusedRectangle     : Integer;
 BarCase                     : TBarCase;
 OldPrevNextRectangle        : Integer;

It seems a matter of alignment. I tested and could extract a 5% speed increase (XP and fpc 2.2.4). With 2.4.0 it may not work like that but is worth a try.

Paulo Costa
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to