1. A method of optimizing a loop in a computer program, the method comprising: (a) inserting an advance load statement that defines a temp with the value of a variable, the advance loading statement being inserted outside the loop; (b) inserting a load check statement in the loop, the load check statement configured to (i) check whether the variable has been written to at any point between the advance load statement and the load check statement; and (ii) if the variable has been written to, define the temp with a current value of the variable; and (c) replacing a statement that occurs in the loop and that uses the variable with a statement that uses the temp.