egcs optimizations acriss function calls

Matthias Urlichs
Tue Sep 1 06:11:00 GMT 1998

> AIUI egcs now does global common subexpression analysis which means
> statements can be reordered over function call boundaries. i.e. in the
> simplest case where myvar is a non-volatile local:
>   myvar++;
>   foo();
>   myvar++;
> egcs will now (I believe) do something like myvar+=2 after the call to
> foo().

No, not yet (except if foo() is inline). egcs doesn't seem to notice that
nobody ever took the address of myvar, and it ignores "register myvar".

It doesn't even move the call to foo() when I mark it as const().

(I tried this with egcs-2.91.53 19980814. The following program, compiled
with -O9 -fno-inline, still increments myvar twice separately.)

const void foo(void) { }
int bar() { return 2; }

int main(int argc,char *argv[])
	register int myvar = bar();
	myvar++; myvar++;
	myvar++; myvar++;
	printf("foo: '%d'\n",fup);
Matthias Urlichs      |        noris network GmbH      |
The quote was selected randomly. Really.    |
I have a marvelous proof of Fermat's last theorem. 
Unforunately my brain is too small to contain it.

More information about the Gcc mailing list