This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: loop unrolling problems


Jeffrey A Law <law@cygnus.com> writes:

  >   In message <in1d7yb99xe.fsf@taurus.oac.uci.edu>you write:
  >   > I thought that gcc might not know that the y[k] store cannot clobber
  >   > x[k] in this case so I tried the equivalent fortran program (with g77):
  > Nope.  GCC does not have the ability to do the analysis to find loop
  > carried dependencies (yet).

Ok. 

I think there still is a problem somewhere, the code generated for the
following 2 programs is different: for the second one for the loop gcc
generates 15 loads and 10 stores, and for the firs one 20 loads and
10 stores (when compiling with -O3 -funroll-all-loops on a sparc). 
As you can see the only difference between the 2 programs is the
location of the arrays.


--first.c--
int
main()
{
  register int    k;
  float  x[1002], y[1002];

  for (k=1; k<=999; k+=2){
    x[k] = y[k+1] - y[k];
    x[k + 1] = y[k + 2] - y[k + 1];
  }
}
--end first.c--

--second.c--
float  x[1002], y[1002];
int
main()
{
  register int    k;

  for (k=1; k<=999; k+=2){
    x[k] = y[k+1] - y[k];
    x[k + 1] = y[k + 2] - y[k + 1];
  }
}
--end second.c--

--dan


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]