Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

using -O3 options with g++

5 views
Skip to first unread message

ami

unread,
Oct 28, 2009, 12:26:33 AM10/28/09
to
hi all i am new to gcc compiler. for my one of application on 64 bit
linux machine i have a doubt whether i should use -O3 or -O2 for
better performance.
as i read in documentation of gcc, -O3 is told to be higher in size
and higher in performance compare to -O2.
but -O3 defaults options enable functions with 600 lines to be inlined
and it breaks the code in huge scale. so is it ok to deliver final
executable with -O3 options or using -O2 as most favoured by
programmer earlier.

also i want to know which one is most prefered by linux programming
professional these days ?
thanks

Jeff Schwab

unread,
Oct 28, 2009, 6:21:17 PM10/28/09
to

Profile. Most of these optimizations are just heuristics; there's no
guarantee that one optimization level will be faster/smaller than another.

RRick

unread,
Nov 20, 2009, 4:46:05 AM11/20/09
to
Several companies I have worked at use -O3 optimization for production
code. For production, they also minimize the debugging information to
-g1. The -g1 option produces some useful symbol information for
backtracing and little else.

The downside of -O3 optimizations is that the debugger info can be
obscured. When you step through the program with -O3 optimization in
a debugger, you can bounce around different parts of the program
without any idea of why it is happening. For a debugging environment,
its best to turn up the debug level to -g3 and turn off the
optimizations to -O0.

0 new messages