The testcase to be attached can be compiled with gfortran -O3 -march=native -ffast-math -funroll-loops -ffree-line-length-200 test.f90
and as discussed in http://gcc.gnu.org/ml/gcc/2009-05/msg00416.html shows some limitations in optimization of gcc 4.3 4.4 and 4.5 -- Summary: missing unrolling/scalarization/reassoc/free Product: gcc Version: 4.5.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: normal Priority: P3 Component: middle-end 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=40168