On 23.09.2010 17:03, Jonas Maebe wrote: > > On 23 Sep 2010, at 16:59, Adrian Veith wrote: > >> I analyzed your code - I think the problem is the array element address >> calculation of the fpc compiler. You have a lot of code like >> Bar[MinValley] etc. The delphi compile uses the lea assembler code for >> this, whereas fpc calculates the address of one element with imul which >> is much slower. > > Please see the last paragraph of > http://lists.freepascal.org/lists/fpc-pascal/2010-September/026510.html > >> Anyway you could speed up your code significantly if you >> help the compiler by reducing the address calculations with the help of >> pointers like this: > > It may help a lot, but only because it will reduce register pressure, > not because the multiplications are gone.
It reduces the total number of multiplications about 70% - I gave the code to one of my guys and he changed the code using pointers to elements wherever possible. This are the differences: fpc - original code: 17s fpc - pointer to elements: 12 s delphi - original code: 9s tested on a AMD notebook. We haven't tested the new code with delphi yet, but the benefits should be marginal compared to fpc. As a conclusion one can say, that fpc's array arithmetic is suboptimal. Cheers, Adrian _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal