* stores inside loops
@ 1997-11-06 14:54 Paul Koning
1997-11-06 15:17 ` Jeffrey A Law
0 siblings, 1 reply; 2+ messages in thread
From: Paul Koning @ 1997-11-06 14:54 UTC (permalink / raw)
To: egcs
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?
paul
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: stores inside loops
1997-11-06 14:54 stores inside loops Paul Koning
@ 1997-11-06 15:17 ` Jeffrey A Law
0 siblings, 0 replies; 2+ messages in thread
From: Jeffrey A Law @ 1997-11-06 15:17 UTC (permalink / raw)
To: Paul Koning; +Cc: egcs
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~1997-11-06 15:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-11-06 14:54 stores inside loops Paul Koning
1997-11-06 15:17 ` Jeffrey A Law
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).