conor@lion.inmos.co.uk (Conor O'Neill) (12/11/90)
In article <5906@stpstn.UUCP> lerman@stpstn.UUCP (Ken Lerman) writes: >2 -- Rather than multiplying by 10, shift left two, add the original > and shift left again. (A smart compiler might do this for you.) > [Some might say that a reasonable compiler should do this for you.] In my working environment, it is faster to multiply by 10 than it is to perform two shifts and an add. A reasonable compiler is far more likely to be able to turn a multiply by a constant into shifts and adds _if_this_is_faster_ than vice-versa. A smart programmer will leave this sort of micro-optimisation to the compiler. --- Conor O'Neill, Software Group, INMOS Ltd., UK. UK: conor@inmos.co.uk US: conor@inmos.com "It's state-of-the-art" "But it doesn't work!" "That is the state-of-the-art".
brnstnd@kramden.acf.nyu.edu (Dan Bernstein) (12/12/90)
In article <13045@ganymede.inmos.co.uk> conor@inmos.co.uk (Conor O'Neill) writes: > A smart programmer will leave this sort of micro-optimisation to the > compiler. No. A smart programmer will consider each optimization on its own merits. Some optimizations will hurt more than they help, and the programmer will leave them to the compiler for each machine. Some optimizations are worth a conditional definition. Some optimizations are always worthwhile. Only a blind programmer will ignore hand optimization if he cares about efficiency. ---Dan