-O vs. -O2

Don Stewart dons at galois.com
Sat May 8 17:52:22 EDT 2010


duncan.coutts:
> On Wed, 2010-05-05 at 21:24 +1000, Roman Leshchinskiy wrote:
> > Whenever I do cabal sdist on one of my projects, I get this warning:
> > 
> > Distribution quality warnings:
> > 'ghc-options: -O2' is rarely needed. Check that it is giving a real benefit
> > and not just imposing longer compile times on your users.
> > 
> > This finally got me curious and I did a nofib run to compare -O to
> > -O2. The results are below (this is with the current HEAD).
> > 
> > Is there a real-world example of -O2 causing significantly longer
> > compile times without providing a real benefit? If not, would it
> > perhaps make sense for Cabal to use -O2 by default or even for GHC to
> > make the two flags equivalent?
> 
> It should be -O1 for default/balanced optimisations and -O2 for things
> involving a bigger tradeoff in terms of code size or compile time. so
> any optimisations in -O2 that GHC HQ believe are a no-brainer for the
> majority of packages should be moved into -O1.

+1

It might be a good time to revise the set of "balanced" optimizations
available at -O1 (-O) level.


More information about the Glasgow-haskell-users mailing list