# O2 vs O3

## Kiroku6

When using compile options, which is faster or better? O2 or O3. I did do a search, but couldnt find anything. I found 1, but it didnt give much info, can some people give me a reccomendation, and some info.

Thanks,

Kikyo

----------

## golloza

O3 implies more optimization than O2 thus it should be faster.

But the binary will be larger and some (few) applications have problems with O3.

I personally use O2.

This might be interesting for you: http://freshmeat.net/articles/view/730/

----------

## Cerement

Well, the definitive answer is the gcc manual.

-O2 is the best general purpose flag

-O3 can be faster but results in larger binaries (and significantly larger binaries when combined with any of the -funroll-loops flags)

Some people have also found that -O3 will actually give slower binaries on Athlons ...

Otherwise, there's 25+ pages of arguments over this very same subject ...

----------

## vonhelmet

 *Kiroku6 wrote:*   

> When using compile options, which is faster or better? O2 or O3. I did do a search, but couldnt find anything. I found 1, but it didnt give much info, can some people give me a reccomendation, and some info.
> 
> Thanks,
> 
> Kikyo

 

Check out man gcc for more info on all this.

----------

## beastmaster

O3 is better, I use that for everything  :Very Happy: 

But I also heard that O3 may break codes more than O2, just because it attempts to optimize stuff "more", sometimes there may be side-effects, such that each program is written differently, and general optimizations may not work for certain one, but I take the risk  :Shocked: 

----------

## u2mike

I've been using -O3 and so far everything I've used has worked fine with that level of optimization.

----------

## Rem

Well, I use -Os (size optimised). I used to use -O3, but I think that the startup times will be faster with smaller binaries. The speed difference in the application itself doesn't matter much for the application I use (at least not on this system).

edit:typo

----------

## Kiroku6

On the topic of CFLAGS. What is the mmmx flag?

----------

## yngwin

 *Kiroku6 wrote:*   

> What is the mmmx flag?

 

To use MMX instructions. For example, I have a Pentium-MMX, so I can specify -march=i586 -mmmx (of course with newer gcc versions there is also -march=pentium-mmx).

----------

