From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jeffrey A Law To: Paul Koning Cc: egcs@cygnus.com Subject: Re: stores inside loops Date: Thu, 06 Nov 1997 15:17:00 -0000 Message-id: <8742.878858341@hurl.cygnus.com> References: <9711062254.AA24732@kona.> X-SW-Source: 1997-11/msg00230.html 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