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 nick...@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

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 constants

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

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

2014-01-19 Thread Ched
Dear Freepascalers, The multiplication in floating arthmetic units is usualy know as being slower than the addition. So, have I interest to code X+X, 2*X or X*2 when using reals (mainly double and extended) ?And with integers ? Can the compiler optimise this operation choosing the fastest one

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

2014-01-19 Thread Philippe
forgot X shl 1 normaly the fastest ... Em 19.01.2014 17:47, Ched escreveu: Dear Freepascalers, The multiplication in floating arthmetic units is usualy know as being slower than the addition. So, have I interest to code X+X, 2*X or X*2 when using reals (mainly double and extended)

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

2014-01-19 Thread Sven Barth
On 19.01.2014 21:07, Philippe wrote: forgot X shl 1 normaly the fastest ... But only for ints, not floating point values. Regards, Sven ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org

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

2014-01-19 Thread Sven Barth
On 19.01.2014 20:47, Ched wrote: Dear Freepascalers, The multiplication in floating arthmetic units is usualy know as being slower than the addition. So, have I interest to code X+X, 2*X or X*2 when using reals (mainly double and extended) ?And with integers ? Can't really comment on floats,

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

2014-01-19 Thread Charles Edouard Des Vastes-Vignes
That is right for positive integers. But for floating point numbers ? Cheers, Raoul Le 19 janv. 2014 21:23, Philippe phili...@quarta.com.br a écrit : forgot X shl 1 normaly the fastest ... Em 19.01.2014 17:47, Ched escreveu: Dear Freepascalers, The multiplication in floating

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

2014-01-19 Thread Nikolay Nikolov
On 01/19/2014 10:45 PM, Sven Barth wrote: On 19.01.2014 20:47, Ched wrote: Dear Freepascalers, The multiplication in floating arthmetic units is usualy know as being slower than the addition. So, have I interest to code X+X, 2*X or X*2 when using reals (mainly double and extended) ?And with