[fpc-pascal] Optimisation : X+X or 2*X or X*2 ?

Sven Barth pascaldragon at googlemail.com
Mon Jan 20 09:29:01 CET 2014


Am 19.01.2014 22:50 schrieb "Nikolay Nikolov" <nickysn at users.sourceforge.net
>:
>
> On 01/19/2014 10:45 PM, Sven Barth wrote:
>>> Can the compiler optimise this operation choosing the fastest one -
>>> probably depending on the architecture x86, arm, aso.
>>
>>
>> It can if someone codes support for it (maybe some code generators
already have such simplifications). I thought I've at least seen such code
for integers (that exactly converts *2 to a shl), but I can't find it
currently...
>
> Integer multiplication by a power of 2 constant is converted to a SHL in
pass 1, see nadd.pas:2869.

Ah, there it is. Thanks. I must have been too tired already when I looked
through the code ^^

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20140120/01373bae/attachment.html>


More information about the fpc-pascal mailing list