Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

About g++ -O option

I run on Ubuntu 10.10.

man g++ talks about -O1, -O2, -O3 optimization options

I noticed that -O5 works also, as well as -O1000...

I used "g++ -v -O5 toto.cpp", but it is not clear to me what's the difference. What does -O5 do actually ?

like image 801
Bob Yoplait Avatar asked Mar 23 '11 16:03

Bob Yoplait


1 Answers

-O5 currently does the same as -O3, as does -O1000. Optimization level 3 is currently the max, but the -O flag accepts a higher level anyway for forward compatibility. Proof:

$ g++ -O2 -Q --help=optimizers > O2
$ g++ -O3 -Q --help=optimizers > O3
$ g++ -O5 -Q --help=optimizers > O5
$ g++ -O1000 -Q --help=optimizers > O1000
$ diff O2 O3
[ ... lots of output]
$ diff O3 O5
$ diff O3 O1000
$
like image 177
Fred Foo Avatar answered Jan 01 '23 10:01

Fred Foo