where can I get gcc optimizations information

Andrew Haley aph@redhat.com
Thu Mar 8 11:00:00 GMT 2007


Juan Castillo writes:

 > I need some help with gcc optimizations and I don't know where I
 > can get it.
 > 
 > The objective of my work is to estimate how many machine
 > instructions I can save in a program execution employing compiler
 > optimizations. I am working with ARM architecture. Anyway, I have
 > understood that main gcc optimizations are
 > architecture-independent.
 > 
 > In the gcc user's manual I have read that flags -O, -O1, -O2, -O3
 > and -Os activate different optimization flags (starting with "-f",
 > I think), but not all of them are available individually. If I
 > switch on all flags available individually for -O1 (-fdefer-pop,
 > -fmerge-constants...) they have no effect in obtained machine code,
 > but if I compile with -O1 option, there is a reduction of about 50%
 > in machine instructions number with respect to basic compilation.
 > 
 > With these results, I suppose that -O1 performs more actions that
 > are not reported in any document I have found in The Internet. I
 > have downloaded the gcc source-code but it is too difficult for me
 > to understand it. My question is: where can I get full information
 > about gcc optimizations and how they are performed?

Full information is in the source.  As Euclid (or someone else!) may
once have said, "There is no royal road to mathematics".  If you are
really to understand, you'll have to get in there some time.

However, some things will help you.  -fverbose-asm produces a list of
optimization passes.  The dumps "-da" and "-fdump-tree-all" produce a
lot of files, one per optimization pass, so you can see what each pass
did.  Once you know which pass does what, you can start to look at the
code.

 > And another question: would be possible to get a benchmark or
 > similar for compiler optimizations? That is, some set of programs
 > that estimate the save that a compiler can achieve. I know it
 > depends on the algotihms compiled, employed architecture and more
 > (please, don't remember me that...). I just need an
 > estimation. That would be great for my work.

SPEC is a standard, but it's unfree and therefore off-topic here.

Andrew.



More information about the Gcc-help mailing list