Looking at the asm for the program below, there plenty of loops left after compiling with
> gfortran -S -march=native -O3 -funroll-loops -funroll-all-loops -fpeel-loops > test.f90 or any combination of these options. A full unrolling (and in that case a return of the value 3) would be possible and much faster. > cat test.f90 INTEGER FUNCTION lxy() lxy=0 DO lxa=0,1 DO lxb=0,0 DO lya=0,1-lxa DO lyb=0,0-lxb lxy=lxy+1 ENDDO ENDDO ENDDO ENDDO END FUNCTION write(6,*) lxy() END -- Summary: unroll/peel loops not aggressive enough Product: gcc Version: 4.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization 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=31040