[fpc-pascal] Branch table

Florian Klämpfl florian at freepascal.org
Sun Aug 26 18:32:29 CEST 2018


Am 26.08.2018 um 11:43 schrieb Giuliano Colla:
> Il 23/08/2018 11:34, Marco Borsari via fpc-pascal ha scritto:
> 
>> It would be for the Wirth optimization in the access of an array,
>> when the index is 0 or 1, allowing the elimination of a multiplication.
> 
> I'm afraid that this sort of optimization is rather outdated, and doesn't take into account a number of factors which
> make modern processors behave quite differently from old times ones.

Multiplication is much less expensive then a jmp in most cases on today's CPUs.

It is even the other way round, it is often useful to replace an if statement by a multiplication like:

if a>b then
  Inc(c,d);

can be replaced on modern CPUs by

Inc(c,d*ord(a>b));



More information about the fpc-pascal mailing list