summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/pr43984.f90
blob: 40c81b84c6c2f5cb19f23e4542d9257622bc609d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
! { dg-do compile }
! { dg-options "-O2 -fno-tree-dominator-opts -fdump-tree-pre" }
module test

   type shell1quartet_type

   integer(kind=kind(1)) :: ab_l_sum
   integer(kind=kind(1)), dimension(:), pointer :: ab_form_3dints_x_indices => NULL()
   integer(kind=kind(1)), dimension(:), pointer :: ab_form_3dints_yz_rms_indices => NULL()

    end type

contains
subroutine make_esss(self,esss)
  type(shell1quartet_type) :: self
  intent(in) :: self
  real(kind=kind(1.0d0)), dimension(:), intent(out) :: esss
  real(kind=kind(1.0d0)), dimension(:), pointer :: Izz
  real(kind=kind(1.0d0)), dimension(:,:), pointer :: Ix,Iy,Iz,Iyz
  integer(kind=kind(1)), dimension(:), pointer  :: e_x,ii_ivec
  integer(kind=kind(1)) :: dim, dim1, nroots, ii,z,y

    dim = self%ab_l_sum+1
    dim1 = self%ab_l_sum+2
    nroots = (dim1) / 2
    call create_(Ix,nroots,dim)
    call create_(Iy,nroots,dim)
    call create_(Iz,nroots,dim)
    call create_(Iyz,nroots,dim*dim1/2)

    e_x => self%ab_form_3dints_x_indices
    ii_ivec => self%ab_form_3dints_yz_rms_indices

    call foo(Ix)
    call foo(Iy)
    call foo(Iz)

    esss = ZERO
    ii = 0
    do z=1,dim
      Izz => Iz(:,z)
      do y=1,dim1-z
        ii = ii + 1
        Iyz(:,ii) = Izz * Iy(:,y)
      end do
    end do
    esss = esss + sum(Ix(:,e_x) * Iyz(:,ii_ivec),1)

end subroutine

end

! There should be three loads from iyz.data, not four.

! { dg-final { scan-tree-dump-times "= iyz.data" 3 "pre" } }
! { dg-final { cleanup-tree-dump "pre" } }