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));
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to