Loop-invariant code motion: Difference between revisions

Content deleted Content added
w/o declaring 'i' locally it has post-loop visibility, so the removal of updates to 'i' may be invalid
No edit summary
Line 30:
 
This code can be optimized further. For example, [[strength reduction]] could remove the two multiplications inside the loop (<code>6*i</code> and <code>a[i]</code>), and [[induction variable]] elimination could then elide <code>i</code> completely. Since <code>6 * i</code> must be in lock step with <code>i</code> itself, there is no need to have both.
 
Further Reading
Aho, Alfred V.; Sethi, Ravi; & Ullman, Jeffrey D. (1986). Compilers: Principles, Techniques, and Tools. Addison Wesley. ISBN 0-201-10088-6.
 
==See also==