LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Set optimization Flag -o3 (https://www.linuxquestions.org/questions/programming-9/set-optimization-flag-o3-832995/)

amarg 09-18-2010 04:49 AM

Set optimization Flag -o3
 
Hi All,

I am looking for the details for C complilation Flag -o3.
Please let me know if some can can help or let me know where I can find details (other than man page). I am looking for pratical examples like why -o3 Flag is used etc.

Thanks,
Amar

xeleema 09-18-2010 04:53 AM

Greetingz!

For the specifics about -O3, check here. It's a section of the main GCC documentation.
Basically, it's the same as -O2, but "more intense".

EDIT: That documentation details exactly what flags are enabled. The -O# series of compilation options being 'aliases' to a predefined set of flags. The documentation goes over each of the individual flags as well.

2nd EDIT: As for why anyone would willing set -O3, its because we like to squeeze every drop of blood performance out of our code (or we like watching things explode).

ryozaui 09-18-2010 02:56 PM

"Note that -O2 is regarded as safer than '-O3', and '-O3' can often be a counter-productive attempt at optimization."

http://en.gentoo-wiki.com/wiki/Safe_Cflags

Also:

"The behavior of gcc has changed significantly since version 3.x. In 3.x, -O3 has been shown to lead to marginally faster execution times over -O2, but this is no longer the case with gcc 4.x."

http://www.gentoo.org/doc/en/gcc-optimization.xml

Read these two references carefully.


All times are GMT -5. The time now is 02:27 PM.