LINUX.IE, website of the Irish Linux Users' Group
Tux rules!

   
Home
New Users
Articles
Download
Projects
Community
Vendors

  Print Version
Email to...
 
Archives:


planetILUG

Recent News

News Archive


Join the
ILUG
on FaceBook


Join the
ILUG
on LinkedIn


Join the
ILUG SETI
Group



















 
 :: Mailing Lists

[ILUG] gcc optimizations

[ILUG] gcc optimizations

hugh hugh at csn.ul.ie
Fri Aug 20 15:45:46 IST 1999


On Fri, 20 Aug 1999, Caolan McNamara wrote:
> with no optimization gcc calls strlen, but with optimization turned on
> gcc converts the strlen call on the literal "test" directly into the
> value 4, which made my day, coz it was what i hoped to see. cute eh..

this form of optimization (afaik) is known as constant folding and/or 
constant propogation.  Basically, any expression that can be calculated at
compile time will be calculated and the result will be used during
run-time.

> But what i wondered was, if there was a list of what gcc does to optimize
> anywhere, or it is just a hodgepodge of magic rules that you have to trawl
> through experimentation or the gcc source to determine.

A reference of what optimizations gcc performs according to what options
you pass it can be found at www.delorie.com/gnu/docs/gcc/gcc_10.html
Each optimization in gcc is complete/modular .. the translated source code
is stored in an intermediate representation (IR) internally and each
optimization makes a "pass" over this, generating a new IR which is used
for the next optimization, until all optimizations are completed.

There is an option to make gcc print out a copy of the IR after each
phase if you want to figure out which phase made the optimization :
gcc -da foo.c
You can also print out the IR after specific phases, see
http://www.delorie.com/gnu/docs/gcc/gcc_9.html for more info.


-hugh





More information about the ILUG mailing list
Read this without the formatting.
                                                                                                    

 

Hosted by HEAnet


Maintained by the ILUG website team. The aim of Linux.ie is to support and help commercial and private users of Linux in Ireland. You can display ILUG news in your own webpages, read backend information to find out how. Networking services kindly provided by HEAnet, server kindly donated by Dell. Linux is a trademark of Linus Torvalds, used with permission. No penguins were harmed in the production or maintenance of this highly praised website. Looking for the Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!
RSS Version
Powered by Dell