jb3o+@andrew.cmu.edu (Jon Allen Boone) writes:
|> What does the -O4 switch do to the SunOS compiler?...
|> "Same as -O3, but trace the effects of pointer assignments."
|> Ok....what does it mean to trace the effects of pointer assignements?

To trace the effects of pointer assignements means to compute alias sets
for pointer assignments. Normally (i.e. with -O3 or lower) the compiler
assumes, that a pointer may write to any variable that can be accessed by
pointers. This includes all global and static variables, arrays and
variables whose address have been taken with the '&' operator.

With -O4 the compiler tries to figure out, to which of these variables a
pointer can actually point. For example, look at the following code:

int i,j;
int a[10],k;
int *pi, *q = &k;

if (...) {
p = &i;
}
else {
p = &j;
}
*p = 123;

Without -O4, the compiler assumes that the assignment '*p = 123' may write
to any variable of {i,j,k,a}. With -O4 the compiler recognizes that '*p =
123' can only affect the variables i and j.

So -O4 has several consequences:
* The compiler must perform additional data flow analysis
* There may be more chances for optimizations
* The compiler may produce 'wrong' code

The last item is common to all optimizing compilers (at least for C),
since aliasing analysis relies on some assumptions that must hold for a
program, e.g. the sequence 'p = &i; *(p+offset) = 123;' will access (a
component of) i, but no other variable. Of course, you cannot enforce this
in C.
--
wismuell@informatik.tu-muenchen.de
Munich University of Technology,
Department of Computer Science, FRG
--