Re: -O4 in SunOS compiler

wismuell@Informatik.TU-Muenchen.DE (Roland Wismueller)
Mon, 31 Aug 1992 14:59:35 GMT

          From comp.compilers

Related articles
-O4 in SunOS compiler jb3o+@andrew.cmu.edu (Jon Allen Boone) (1992-08-26)
Re: -O4 in SunOS compiler wismuell@Informatik.TU-Muenchen.DE (1992-08-31)
Re: -O4 in SunOS compiler chased@rbbb.Eng.Sun.COM (1992-09-01)
Re: -O4 in SunOS compiler khb@chiba.Eng.Sun.COM (1992-09-01)
Re: -O4 in SunOS compiler fjh@mundil.cs.mu.OZ.AU (1992-09-02)
-O4 in SunOS compiler dolf@toet.echo.tds.philips.nl (1992-09-03)
Re: -O4 in SunOS compiler Alfred.Kayser@dnpap.et.tudelft.nl (1992-09-04)
| List of all articles for this month |

Newsgroups: comp.compilers
From: wismuell@Informatik.TU-Muenchen.DE (Roland Wismueller)
Organization: Technische Universitaet Muenchen, Germany
Date: Mon, 31 Aug 1992 14:59:35 GMT
Originator: wismuell@sunbode7.informatik.tu-muenchen.de
References: 92-08-164
Keywords: sparc, optimize, C

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
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.