On Sun, 26 Aug 2018 18:32:29 +0200
Florian Klämpfl <flor...@freepascal.org> wrote:

> 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));

Ah I see, anyway I did not think that, as Giuliano said, beacuse of alignment of
array element, the multiplication is already substituded by a shift, and the 
essence
of a branch table becomes superflous. Thank you for your time,
Marco
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to