This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug fortran/55100] New: FORALL: If the RHS is scalar, not array temporary is needed


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]