Microoptimisations (Was Re: Efficient way to transform float to string)

Conor O'Neill conor at lion.inmos.co.uk
Wed Dec 12 00:44:14 AEST 1990


In article <5906 at stpstn.UUCP> lerman at 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 at inmos.co.uk		US: conor at inmos.com
"It's state-of-the-art" "But it doesn't work!" "That is the state-of-the-art".



More information about the Comp.lang.c mailing list