move loop invariant out of loop (minor)