PRE currently ends up inserting expressions into loops. 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 look for insertions of iyz.data for example. -- Summary: PRE misses full-redundancies, inserts into loops Product: gcc Version: 4.6.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: enhancement Priority: P3 Component: tree-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: rguenth at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43984