[fpc-pascal] code optimization
jonas.maebe at elis.ugent.be
Wed Sep 22 17:24:30 CEST 2010
On 22 Sep 2010, at 16:08, stefan077 at web.de wrote:
> Thus it looks like FPC pascal is doing very bad on optimizing the
> I agree, that I also have seen examples where FPC pascal code is
> about 10% faster than Delphi code.
> So why does FPC pascal fail on this code?
At first sight it looks like FPC makes less efficient use of the
available registers. Other than from the machine code, it's also
indicated by the program being just as fast on my PowerMac G5/1.8GHz
as on an AMD Opteron 2356 at 2.3GHz (normally pretty much any
reasonably modern non-netbook-class x86 trounces my 6 year old Mac
regardless of the clock speed and of what you throw at them :).
Interestingly, the program becomes about 20% slower when compiled by
FPC for x86-64, which is odd because more registers are available
there (only half as many as on the PowerPC, but still...).
Delphi (Kylix) also uses a trick to avoid some multiplies with a small
constant, but that has almost no influence on modern x86 cpus (the
time of the FPC-compiled program barely changes if you manually apply
that trick to the generated code).
More information about the fpc-pascal