Loop-invariant code motion: Difference between revisions

Content deleted Content added
top: rm unclear subsentence: precisely what doesn't change: source text?, statement semantices as mapping from memory states to memory states (insufficient for code motion)?, computed value of an expression (undefined for arbitrary statements)?
Line 1:
{{Unreferenced|date=May 2007}}
 
In [[computer programming]], '''[[loop-invariant code]]''' consists of statements or expressions (in an [[imperative programming|imperative]] [[programming language]]) which can be moved outside the body of a loop without affecting the semantics of the program, because it does not change during the loop: they are [[loop invariant]]s. '''Loop-invariant code motion''' (also called '''hoisting''' or '''scalar promotion''') is a [[compiler optimization]] which performs this movement automatically.
 
==Example==