Im game programming and as you know that means time is a huge concern. Im going through my functions and trying to speed them up since they all run many many times a second. So my question is which is faster, a muliplication of a variable or an unrolled addition.
ex: total = 2 * x;
or total = x+x;
does anyone know for a fact?
Also, what difference will it make between a float or an int x. Is it only better to unroll with an int, etc?
Finally, if im multiplying by a bigger number does it become less effective. Like 5*x is faster than x+x+x+x+x but 2*x is slower than x+x. The higher the coefficient the more additions it would need and the more calls to the variable it makes so that sounds bad. So basically is there any knowledgeable person who could fill me in on this stuff?