Using today's trunk with http://gcc.gnu.org/ml/fortran/2010-08/msg00003.html
applied.

The following example were extracted from FLEUR (www.flapw.de), where
-Warray-temporaries showed that a temporary has been generated.

!-- ONE ----------------------
      subroutine t1(n1,n2, gfft, ufft)
        implicit none
        integer :: n1, n2, i
        real :: gfft(n1,n2), ufft(n2)
        DO i=1, n1
          gfft(i,:)=gfft(i,:)*ufft(i)  ! No temporary needed
        END DO
      end subroutine

!-- TWO ----------------------
   we(1:noccbd) = we(n_start:n_end)

If "1" is the (known) lower bound, no temporary is needed (if one copies from
the lower to the upper bound). Using memmove also no temporary is needed (as it
allows for this) - using memcpy this is not possible (memory needs to be
disjunct). For this case of having on the RHS only a variable, one should
probably do a middle-end assignment with ARRAY_RANGE_REF. Cf. PR 40598.


!-- THREE ----------------------

   wannint(pw1,pw2,pw3,:)=wannint(pw1,pw2,pw3,:)+wannz2(j,:)

gets a temporary generated (no pointer - and no target with argument aliasing
involved.)


-- 
           Summary: Unneccessary temporaries
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: burnus at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45159

Reply via email to