Really simply question, really. Is it worth declaring a temporary (float) variable to reduce an operation from 2 to 1 multiplies?
x = a * b / c;
y = a * b / d;
float ab = a * b;
x = ab / c;
y = ab / d;
I'm not very familiar with assembly language, or how everything breaks down when its compiled, so that's why I'm asking. I'm not trying to optimize (really), I'm actually hoping to do the opposite (avoid the temporaries). If the function wasn't part of my math library, I probably wouldn't even bother worrying about it. The method I'm writing generates the (matrix-like) direction vectors of a quaternion. In the method, there are 2 of 9 unique multiplies, which means I could either multiply 18 times, or declare 9 variables and multiply 9 times.
I originally wrote the function by declaring the temporary variables, but it would look a lot nicer to simply do the math twice, as long as the difference is negligible.
Thanks a bunch for any advice