How to troubleshoot long compile times?

There was a thread Oddly slow compilation of character data with ifx

I don’t know if it’s relevant to your code, but gfortran compiles implied do-loops with large bounds slowly. (Does Intel?) For example it takes 7 s on my Windows PC to compile

implicit none
integer, parameter :: n = 10**7, dp = kind(1.0d0)
integer :: i, v(n)
v = [(i, i=1,n)]
print*,sum(real(v, kind=dp))
end

but just 0.1 s for the equivalent program with a do loop.