Code motion optimization on for loops.