Loop-invariant code motion: Difference between revisions

Content deleted Content added
Optimization is incorrect when n <= 0
Line 13:
</source>
 
TheAssuming n > 0, the calculation <code>x = y + z</code> and <code>x * x</code> can be moved outside the loop since within they are [[loop-invariant code]], so the optimized code will be something like this:
 
<source lang="C">