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: stores inside loops



  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


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