LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 01-11-2007, 04:09 PM   #1
andystanfordjason
Member
 
Registered: Oct 2006
Location: england
Distribution: fedora 6
Posts: 38

Rep: Reputation: 15
optimizing c


hello, im currently writing a program in c and i would really like to know what optimizations gcc preforms on my code. if possible can you still see the code with the optimizations before the compiler turns it to machine code or, even better, before it turns it to assembly. thanks a lot
 
Old 01-11-2007, 04:26 PM   #2
tuxdev
Senior Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 2,014

Rep: Reputation: 115Reputation: 115
Check out all the -f options in "man gcc". The optimization levels are really just pre-defined combinations of those -f options. For assembly output use -S.
 
Old 01-11-2007, 06:09 PM   #3
andystanfordjason
Member
 
Registered: Oct 2006
Location: england
Distribution: fedora 6
Posts: 38

Original Poster
Rep: Reputation: 15
i want to use the -O3 option but see what that does to me c code really or anything close to that, i.e. see my code optimized by the compiler. thanks anyhow
 
Old 01-11-2007, 06:30 PM   #4
wjevans_7d1@yahoo.co
Member
 
Registered: Jun 2006
Location: Mariposa
Distribution: Slackware 9.1
Posts: 938

Rep: Reputation: 30
As tuxdev says: use the -S option to see the assembler output. Compare the output with and without the -O3 option.
 
Old 01-11-2007, 06:34 PM   #5
andystanfordjason
Member
 
Registered: Oct 2006
Location: england
Distribution: fedora 6
Posts: 38

Original Poster
Rep: Reputation: 15
cheers thats probably enough for me to solve the problem. just one more thing on this matter: is there anything between the preprocessed c and assembly? thanks
 
Old 01-11-2007, 06:40 PM   #6
tuxdev
Senior Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 2,014

Rep: Reputation: 115Reputation: 115
I heard that GCC parses all supported languages to RTL (Register Transfer Language), then optimizes that. There may be a way to get at it, but I don't really know that much about GCC internals.
 
Old 01-13-2007, 09:38 PM   #7
sundialsvcs
Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 5,420

Rep: Reputation: 1157Reputation: 1157Reputation: 1157Reputation: 1157Reputation: 1157Reputation: 1157Reputation: 1157Reputation: 1157Reputation: 1157
The main reason why you do not see an "assembly listing" anymore is that there isn't a one-to-one correspondence between the code you write and the instruction-stream that is produced. They are functionally equivalent but they do not correspond.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
optimizing slack saurabhp_75 Slackware - Installation 3 03-01-2005 08:26 AM
Optimizing Mandrake rokka Mandriva 9 12-14-2004 08:21 PM
Apache optimizing Hamma Linux - Software 8 12-08-2003 08:44 PM
Optimizing Debian monkeymartin Debian 3 08-22-2003 01:12 PM
optimizing linux centr0 Linux - General 3 03-13-2003 05:12 PM


All times are GMT -5. The time now is 06:39 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration