This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: loop unrolling problems
- To: law at cygnus dot com
- Subject: Re: loop unrolling problems
- From: Dan Nicolaescu <dann at godzilla dot ics dot uci dot edu>
- Date: 02 Jul 1999 01:00:56 -0700
- Cc: egcs at egcs dot cygnus dot com
- References: <32224.930893345@upchuck.cygnus.com>
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