public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/55100] New: FORALL: If the RHS is scalar, not array temporary is needed
@ 2012-10-27 17:22 burnus at gcc dot gnu.org
  0 siblings, 0 replies; only message in thread
From: burnus at gcc dot gnu.org @ 2012-10-27 17:22 UTC (permalink / raw)
  To: gcc-bugs


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

             Bug #: 55100
           Summary: FORALL: If the RHS is scalar, not array temporary is
                    needed
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: burnus@gcc.gnu.org


As the dump shows, gfortran generates a temporary array in this case. While a
temporary is needed, a scalar temporary is sufficient if/as the RHS is a scalar
(or a an array element which doesn't depend on the forall index).

implicit none
type inner
  integer :: i = 5
end type inner
type t
  integer :: i
  type(inner), pointer :: str
end type t

type(t), pointer :: y(:)
type(inner), target :: tgt
integer :: i, n
n = 10

allocate(y(n))
forall(i=1:n) y(i)%str => null() ! Ok, no tmp needed
forall(i=1:n) y(i)%i = 5 ! Ok, no tmp needed
do i = 1, n
  if (associated(y(i)%str)) stop 'ERROR'
  if (y(i)%i /= 5) stop 'ERROR'
end do
forall(i=1:n) y(i)%str => tgt ! Only scalar tmp needed
do i = 1, n
  if (.not. associated(y(i)%str,tgt)) stop 'ERROR'
end do
! Pointless assignment of the value from tgt to tgt
forall(i=1:n) y(i)%str = tgt  ! Only scalar tmp needed
end


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2012-10-27 17:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-27 17:22 [Bug fortran/55100] New: FORALL: If the RHS is scalar, not array temporary is needed burnus at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).