Expected: The following loop is optimized way using gfortran -O3. ------------ program prova implicit none integer :: i, j, Nx, Ny parameter(Nx=10000,Ny=10000) real(8) :: A(Nx,Ny) do j=1,Ny do i=1,Nx A(i,j)=sin(1.d0+i+j); end do end do end program ------------
In an equivalent C program the loop is optimized away and the run time drops from 10.927s to 0.001s: gcc -O3 ------------ #include <math.h> #define NX 10000 #define NY 10000 int main() { double A[NX][NY]; int i, j; for(i = 0; i < NX; i++) for(j = 0; j < NY; j++) A[i][j] = sin(3.0+i+j); return 0; } -- Summary: optimization: Loop not optimized away Product: gcc Version: 4.3.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: normal Priority: P3 Component: middle-end AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: burnus at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31892