[fpc-devel] static vs dynamic arrays

Jonas Maebe jonas.maebe at elis.ugent.be
Tue Apr 4 11:48:07 CEST 2006


On 4 apr 2006, at 11:41, Пётр Косаревский wrote:

>> They are equally fast if you turn on register variables and if enough
>> free registers are available (e.g. on a PPC; possibly also on an x86
>> if you have a very simple loop and little or no variables used both
>> before and after the loop).
>
> It's wrong.

bigmac:~/fpc/test jonas$ ppcppc69 -O3 tarr
Target OS: Darwin for PowerPC
Compiling tarr.pp
Assembling testdynstat
Linking tarr
43 Lines compiled, 0.3 sec
bigmac:~/fpc/test jonas$ ./tarr
Enter dyn array len (1-1000000):1000000
Total:4789ms
Total:4809ms
bigmac:~/fpc/test jonas$ ./tarr
Enter dyn array len (1-1000000):1000000
Total:4897ms
Total:4787ms

> About the number of variables: you saw the whole source of the  
> sample program.
>
> About register variables: I compiled it with -O3rp4 options.

2.0.2 has less efficient register variable allocation. And your  
program requires 9 permanently free registers to be able to make  
optimal use of regvars. That is impossible to achieve on an x86,  
since in the best case you only have 7 (and usually less, since you  
need some scratch registers as well and ebp is occupied most of the  
time).


Jonas


More information about the fpc-devel mailing list