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

            Bug ID: 57262
           Summary: Optimize bound intrinsics with dim=var for rank one
                    arrays
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: minor
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: burnus at gcc dot gnu.org

I am not really sure whether this really occurs in real-world code, but I
realized that for rank=1 arrays, the following can be compile-time simplified.

! { dg-options "-fdump-tree-original" }

integer function foo(i)
  implicit none
  integer :: i, a(10)
  foo = lbound (a, dim=i) + 2*ubound(a,dim=i) + 3*size(a,dim=i)
end

! { dg-final { scan-tree-dump "__result_bar = 51;" "original" } }

!
! * * *
!
! For the tree version, one could also replace the dim=i by dim=1:

integer function bar(jjj,n)
  implicit none
  integer :: jjj, n, a(n:)
  bar = lbound (a, dim=jjj) + 2*ubound(a,dim=jjj) + 3*size(a,dim=jjj)
end
! { dg-final { scan-tree-dump-not "jjj" "original" } }

Reply via email to