Arithmetic Constructions

Wherever possible, use multiplication rather than division. For example:

x*(1.0/3.0);

produces faster code than:

x/3.0;

Assigning the reciprocal of the divisor to a temporary variable and then multiplying by that variable is beneficial, especially if you divide many values by the same number in your code. This is attempted by the compiler when the -O3 option is specified.



Writing Optimized Code...
    Overview
    Variables
    Pointers
    Functions
    Function Arguments
    Expressions
    Critical Loops
    Conversions
    Inlined Components