Unroll loops in inner-to-outer order