User account creation filtered due to spam.

Bug 31892 - optimization: Loop not optimized away because of static
Summary: optimization: Loop not optimized away because of static
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.3.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: missed-optimization
Depends on:
Blocks:
 
Reported: 2007-05-10 10:08 UTC by Tobias Burnus
Modified: 2012-02-01 20:17 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2012-02-01 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Burnus 2007-05-10 10:08:00 UTC
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;
}
Comment 1 Andrew Pinski 2012-02-01 20:17:47 UTC
Confirmed, the issue is the fortran front-end promotes A to being static.  Maybe we should just add code to the middle-end that does that.