This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: stores inside loops
- To: Paul Koning <pkoning at xedia dot com>
- Subject: Re: stores inside loops
- From: Jeffrey A Law <law at cygnus dot com>
- Date: Thu, 06 Nov 1997 16:19:01 -0700
- cc: egcs at cygnus dot com
- Reply-To: law at cygnus dot com
In message <9711062254.AA24732@kona.>you write:
> I'm seeing a lack of optimization that surprises me...
>
> Given the following:
>
> extern int a[100], b[100];
> extern int s;
>
> void foo(void)
> {
> int i;
> s = 0;
> for (i=0;i<100;i++)
> s += a[i] * b[i];
> }
>
> I did gcc -O3 -S for {arm, sparc, mips64, x86} and on all of these
> ended up with code that does the load and store of "s" INSIDE the
> loop.
>
> Given that s is not declared volatile I had expected that the
> optimizer would move the load and store outside the loop. Was that an
> unreasonable expectation?
Not unreasonable, just not implemented (yet :-).
The new alias code from jfc will be a big help with the time comes to
implement this optimization.
jeff