I have a C-coded function that realizes a very long calculation on a microcontroller. I try to optimize it for speed at the moment. The function content is created automatically using Mathematica. It has hundreds of calculations and looks like this:
void calcResult(float *result, float arg1, float arg2, ... float argN){
float tmp1 = arg1 * 2 + arg2;
float tmp2 = tmp1/arg3 + tmp1;
...
...
float tmpN = tmp320 + tmp15 * 2;
*result = tmp2 + tmpN;
}
I asked myself if it could possibly be faster not use "tmp" variables but an array with the same size as the number of "tmp" variables or maybe to speed things up in such a function in another way (under the assumption, that the calculations to get the "result" are already "optimized" in terms of the necessary calculation time)?
Edit:
In my opinion Is micro-optimisation important when coding? doesn't answer my specific question, even if the goal is to optimise the code as well.