Extract SCEV generation into subfunction

This makes the code more readable and will be reused in subsequent OpenMP
patches.