This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/48025] New: Unnecessary function evaluations in arguments to size and ubound
- From: "tkoenig at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 7 Mar 2011 19:40:12 +0000
- Subject: [Bug fortran/48025] New: Unnecessary function evaluations in arguments to size and ubound
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48025
Summary: Unnecessary function evaluations in arguments to size
and ubound
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: enhancement
Priority: P3
Component: fortran
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: tkoenig@gcc.gnu.org
ig25@linux-fd1f:~/Krempel/Size> cat size.f90
subroutine foo(a,b,n,m,k, i)
implicit none
integer, intent(in) :: n
real, dimension(n,n) :: a,b
integer, intent(out) :: m,k,i
m = size(matmul(a,b))
k = size(sum(a,1))
i = size(maxloc(a,1))
m = ubound(matmul(a,b),1)
k = ubound(sum(a,1),1)
i = ubound(maxloc(a,1),1)
end
ig25@linux-fd1f:~/Krempel/Size> gfortran -S -O -fdump-tree-optimized size.f90
ig25@linux-fd1f:~/Krempel/Size> grep _gfortran size.s
call _gfortran_matmul_r4
call _gfortran_size0
call _gfortran_sum_r4
call _gfortran_maxloc1_4_r4
call _gfortran_matmul_r4
call _gfortran_sum_r4
call _gfortran_maxloc1_4_r4
None of the function calls is needed to calculate the size; this
could be done during simplification or optimization.