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

2014-01-20 Thread Sven Barth
Am 19.01.2014 22:50 schrieb "Nikolay Nikolov" : > > 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

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

2014-01-20 Thread Michael Schnell
On 01/19/2014 09:45 PM, Sven Barth wrote: Can't really comment on floats, but for integers the fasted to multiply by 2 should be a shift left. GCC automatically optimizes this. With the small "embedded" CPUs I usually use, it even converts more most multiplications and divisions with constant

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

2014-01-20 Thread Mark Morgan Lloyd
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 intege