Talk:Loop-invariant code motion
Appearance
The page originally had the following:
This can then be further optimized, leading to less overall executed code for larger values of maxval and/or smaller values of calcval.
int calcval = (4+array[k])*pi+5;
j = j + integer_part((maximum - 1 - j) / calcval) * calcval;
However, that transformation is not "loop-invariant code motion". In any case it is not obviously correct when maximum is near overflow (well, OK, maybe it's undefined behaviour then, but suppose that maximum was unsigned).