[fpc-pascal] code optimization

Jonas Maebe jonas.maebe at elis.ugent.be
Fri Sep 24 10:37:48 CEST 2010


On 24 Sep 2010, at 08:06, Adrian Veith wrote:

> On 23.09.2010 17:03, Jonas Maebe wrote:
>>
>> 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.

Note the above: he changed the code using pointers. He did not replace  
the multiplications with "lea" instructions. Simply replacing the  
multiplications with lea instructions has almost no influence on the  
speed, as I mentioned twice before (unless you have a very old x86).  
Multiplications, especially with small numbers, are very fast on  
modern processors.

> This are the differences:
>
> fpc - original code: 17s
> fpc - pointer to elements: 12 s
> delphi - original code: 9s

Yes, because as I mentioned above, this reduces the register pressure.

> As a conclusion one can say, that fpc's array arithmetic is  
> suboptimal.

You can conclude that, but that is virtually completely unrelated to  
the speed of this example program.


Jonas



More information about the fpc-pascal mailing list