LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   optimizing c (http://www.linuxquestions.org/questions/programming-9/optimizing-c-518447/)

andystanfordjason 01-11-2007 03:09 PM

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

tuxdev 01-11-2007 03:26 PM

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.

andystanfordjason 01-11-2007 05:09 PM

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

wjevans_7d1@yahoo.co 01-11-2007 05:30 PM

As tuxdev says: use the -S option to see the assembler output. Compare the output with and without the -O3 option.

andystanfordjason 01-11-2007 05:34 PM

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

tuxdev 01-11-2007 05:40 PM

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.

sundialsvcs 01-13-2007 08:38 PM

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.


All times are GMT -5. The time now is 05:04 PM.