Re: performance gcc vs other compilers?

jfc@mit.edu (John Carr)
6 Apr 1996 22:18:26 -0500

          From comp.compilers

Related articles
performance gcc vs other compilers? wchuang@inews.intel.com (Weihaw Chuang) (1996-03-29)
Re: performance gcc vs other compilers? cdg@nullstone.com (1996-04-02)
Re: performance gcc vs other compilers? jfc@mit.edu (1996-04-06)
| List of all articles for this month |

From: jfc@mit.edu (John Carr)
Newsgroups: comp.compilers
Date: 6 Apr 1996 22:18:26 -0500
Organization: Massachusetts Institute Of Technology
References: 96-03-211
Keywords: GCC, performance

Weihaw Chuang <wchuang@inews.intel.com> wrote:


>I'm doing this project in my spare time to learn about compiler
>optimizations so if anyone can give me more pointers, I'd really
>appreciate it.


The basic rule: every compiler has some blind spots, even highly
optimizing compilers. One can always find code to make a compiler
look bad.


Read the performance tuning section of the compiler manual and the
list of options. Usually each optimization level will have a list of
optimizations performed at that level. Sometimes the optimizations
will be described but more often they will just be listed by name.


Sometimes there are debugging flags to print information about
specific optimization passes. These flags are generally hard to find
out about. On UNIX you can run "strings" on the binary and look for
embedded text related to option processing; this may be a technical
violation of your license.


There are usually additional options beyond the basic -O1, -O2, etc.
Some of these enable specific optimizations in stanard code; others
declare that the source does not use certain features of applicable
standards. For example, that Sun's compiler allows one to declare
that pointer arguments to a function do not alias each other. The
existence of this option implies that Sun's compiler does some pointer
alias analysis.


Try compiling the same source with and without certain options and
comparing the resulting machine code.


GNU C tends to be good at micro-optimizations. This is partially a
result of the way it is maintained. It is a lot easier to write a
small change to recognize an algebraic identity or an alternate form
of a short instruction sequence than it is to implement (for example)
global alias analysis. There are also complicated interactions among
components making certain types of changes difficult. GNU C is also
good at compiling itself and GNU emacs. gcc-compiled gcc is about 10%
faster than gcc compiled with Sun's compiler at high optimization.


--
        John Carr (jfc@mit.edu)
--


Post a followup to this message

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