in the function F1 below, gfortran generates calls to _gfortran_size1 which (I believe) makes that function about a factor 2-3 slower than should be. In principle the optimizer should/could realize that size(a) is invariant, and at least move it out of the loop.
> cat test.f90 INTEGER FUNCTION F1(a) integer :: a(:,:) F1=0 DO k=1,SIZE(a,2) DO j=1,SIZE(a,1) F1=F1+a(j,k) ENDDO ENDDO END FUNCTION F1 [EMAIL PROTECTED]:~> cat main.f90 INTERFACE INTEGER FUNCTION F1(a) integer :: a(:,:) END FUNCTION END INTERFACE INTEGER :: a(2,2),i,s a=0 DO i=1,100000000 s=s+F1(a) ENDDO END [EMAIL PROTECTED]:~> ifort -O3 -xW test.f90 main.f90 ; time ./a.out main.f90(9): (col. 1) remark: (irrelevant) LOOP WAS VECTORIZED. real 0m1.381s user 0m1.376s sys 0m0.004s [EMAIL PROTECTED]:~> gfortran -O3 -march=native test.f90 main.f90 ; time ./a.out real 0m3.578s user 0m3.576s sys 0m0.000s -- Summary: calls to SIZE not optimized out of loops Product: gcc Version: 4.4.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: normal Priority: P3 Component: fortran AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: jv244 at cam dot ac dot uk http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38181