ghc -O

Ben Lippmeier Ben.Lippmeier at
Wed Jan 23 20:05:00 EST 2008

Hi Matt,
No, I don't think anything extra is done in the native code generator 
when -O or -O2 are enabled. I believe that strictness information is 
used in the core stages only, eg to change let bindings (which allocate 
thunks) to case expressions (which don't) - but I haven't worked on the 
GHC core so I'm not that familiar with it.

There's a plan to turn on the iterative register allocator that I wrote 
with -O2, but the STG to C-- translation needs to be improved before 
that will have much effect on performance. This is currently being 
completely overhauled by Norman Ramsey and co, so perhaps in 6.10.


Matthew Naylor wrote:
> Hello GHC gurus,
> specifying "-O" or "-O2" to GHC enables various optimisations to the
> frontend of the compiler, but I wonder does it turn on any
> optimistions to the backend/code-generator that are independent of the
> frontend?
> I can imagine that knowledge such as strictness which is computed by
> frontend would enable optimisations in the backend, but I'm more
> interested in whether the backend would do anything independent (e.g.
> peephole optimistion, C compiler options) with "-O" but not without.
> Thanks,
> Matt.
> _______________________________________________
> Glasgow-haskell-users mailing list
> Glasgow-haskell-users at

More information about the Glasgow-haskell-users mailing list