home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!darwin.sura.net!udel!gvls1!faatcrl!iecc!compilers-sender
- From: wismuell@Informatik.TU-Muenchen.DE (Roland Wismueller)
- Newsgroups: comp.compilers
- Subject: Re: -O4 in SunOS compiler
- Keywords: sparc, optimize, C
- Message-ID: <92-09-003@comp.compilers>
- Date: 31 Aug 92 14:59:35 GMT
- References: <92-08-164@comp.compilers>
- Sender: compilers-sender@iecc.cambridge.ma.us
- Reply-To: wismuell@Informatik.TU-Muenchen.DE (Roland Wismueller)
- Organization: Technische Universitaet Muenchen, Germany
- Lines: 47
- Approved: compilers@iecc.cambridge.ma.us
- Originator: wismuell@sunbode7.informatik.tu-muenchen.de
-
- 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
- --
- Send compilers articles to compilers@iecc.cambridge.ma.us or
- {ima | spdcc | world}!iecc!compilers. Meta-mail to compilers-request.
-