1! { dg-do compile }
2! { dg-options "-O2 -fdump-tree-fre1 -fdump-tree-pre-details" }
3
4subroutine  eval(foo1,foo2,foo3,foo4,x,n,nnd)
5  implicit real*8 (a-h,o-z)
6  dimension foo3(n),foo4(n),x(nnd)
7  nw=0
8  foo3(1)=foo2*foo4(1)
9  do i=2,n
10    foo3(i)=foo2*foo4(i)
11    do  j=1,i-1
12      temp=0.0d0
13      jmini=j-i
14      do  k=i,nnd,n
15        temp=temp+(x(k)-x(k+jmini))**2
16      end do
17      temp = sqrt(temp+foo1)
18      foo3(i)=foo3(i)+temp*foo4(j)
19      foo3(j)=foo3(j)+temp*foo4(i)
20    end do
21  end do
22end subroutine eval
23
24! We should have hoisted the division
25! { dg-final { scan-tree-dump "in all uses of countm1\[^\n\]* / " "pre" } }
26! There should be only one load from n left
27! { dg-final { scan-tree-dump-times "\\*n_" 1 "fre1" } }
28! { dg-final { cleanup-tree-dump "fre1" } }
29! { dg-final { cleanup-tree-dump "pre" } }
30