Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
-O2 vs -O3
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Duplicate Threads
View previous topic :: View next topic  
Author Message
Patr|ck_
n00b
n00b


Joined: 09 Apr 2005
Posts: 69

PostPosted: Thu Sep 22, 2005 4:49 pm    Post subject: -O2 vs -O3 Reply with quote

Which do you guys use in your CFLAGS, -O2 or -O3? Currently I use -O3, as I've seen some better performance with it, but what do you guys think about either flag? Have you noticed performance increases? Compiling nbench-2.2.2 with -O3 gave me about 200 more points in Numeric Sort than with -O2...
Back to top
View user's profile Send private message
Dlareh
Advocate
Advocate


Joined: 06 Aug 2005
Posts: 2102

PostPosted: Thu Sep 22, 2005 4:52 pm    Post subject: Re: -O2 vs -O3 Reply with quote

Patr|ck_ wrote:
Compiling nbench-2.2.2 with -O3 gave me about 200 more points in Numeric Sort than with -O2...
:roll:

-O3 bloats binaries !!!!111eleven1onetwo
_________________
"Mr Thomas Edison has been up on the two previous nights discovering 'a bug' in his phonograph." --Pall Mall Gazette (1889)
Are we THERE yet?
Back to top
View user's profile Send private message
i92guboj
Bodhisattva
Bodhisattva


Joined: 30 Nov 2004
Posts: 10306
Location: Córdoba (Spain)

PostPosted: Thu Sep 22, 2005 4:52 pm    Post subject: Reply with quote

There are thousands of topics regarding this thing in the forums. So I will not continue it here. Just search around. All is about opinions, the only truth about this topic is in the gcc man page, the rest are just speculations:

Code:

Not all optimizations are controlled directly by a flag.  Only optimizations that have a flag are listed.

       -O
       -O1 Optimize.  Optimizing compilation takes somewhat more time, and a lot more memory for a large function.

           With -O, the compiler tries to reduce code size and execution time, without performing any optimizations that take a great deal of compila-
           tion time.

           -O turns on the following optimization flags: -fdefer-pop -fmerge-constants -fthread-jumps -floop-optimize -fif-conversion -fif-conversion2
           -fdelayed-branch -fguess-branch-probability -fcprop-registers

           -O also turns on -fomit-frame-pointer on machines where doing so does not interfere with debugging.

       -O2 Optimize even more.  GCC performs nearly all supported optimizations that do not involve a space-speed tradeoff.  The compiler does not
           perform loop unrolling or function inlining when you specify -O2.  As compared to -O, this option increases both compilation time and the
           performance of the generated code.

           -O2 turns on all optimization flags specified by -O.  It also turns on the following optimization flags: -fforce-mem -foptimize-sib-
           ling-calls -fstrength-reduce -fcse-follow-jumps  -fcse-skip-blocks -frerun-cse-after-loop  -frerun-loop-opt -fgcse  -fgcse-lm  -fgcse-sm
           -fgcse-las -fdelete-null-pointer-checks -fexpensive-optimizations -fregmove -fschedule-insns  -fschedule-insns2 -fsched-interblock
           -fsched-spec -fcaller-saves -fpeephole2 -freorder-blocks  -freorder-functions -fstrict-aliasing -funit-at-a-time -falign-functions
           -falign-jumps -falign-loops  -falign-labels -fcrossjumping

           Please note the warning under -fgcse about invoking -O2 on programs that use computed gotos.

       -O3 Optimize yet more.  -O3 turns on all optimizations specified by -O2 and also turns on the -finline-functions, -fweb and -frename-registers
           options.

       -O0 Do not optimize.  This is the default.

       -Os Optimize for size.  -Os enables all -O2 optimizations that do not typically increase code size.  It also performs further optimizations
           designed to reduce code size.

           -Os disables the following optimization flags: -falign-functions  -falign-jumps  -falign-loops -falign-labels  -freorder-blocks
           -fprefetch-loop-arrays

           If you use multiple -O options, with or without level numbers, the last such option is the one that is effective.

_________________
Gentoo Handbook | My website
Back to top
View user's profile Send private message
Earthwings
Bodhisattva
Bodhisattva


Joined: 14 Apr 2003
Posts: 7753
Location: Karlsruhe, Germany

PostPosted: Thu Sep 22, 2005 5:23 pm    Post subject: Reply with quote

Moved from Portage & Programming to Duplicate Threads in favour of CFLAGS Central Part 1, 2.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Duplicate Threads All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum