Add -faggressive-primops plus refactoring in CoreUtils
authorSimon Peyton Jones <simonpj@microsoft.com>
Fri, 13 Jan 2012 17:50:00 +0000 (17:50 +0000)
committerSimon Peyton Jones <simonpj@microsoft.com>
Fri, 13 Jan 2012 17:50:00 +0000 (17:50 +0000)
commit601c983dd0bada6b49bdadd8f172fd4eacac4b0c
tree58c99eb2753958b5a0192ec050a385b9badcc847
parentc96022cbfae44ea9180b78e3c37467613ac98cec
Add -faggressive-primops plus refactoring in CoreUtils

I'm experimenting with making GHC a bit more aggressive about
  a) dropping case expressions if the result is unused
        Simplify.rebuildCase, CaseElim equation

  b) floating case expressions inwards
        FloatIn.fiExpr, AnnCase

In both cases the new behaviour is gotten with a static (debug)
flag -faggressive-primops.  The extra "aggression" is to allow
discarding and floating in for side-effecting operations.  See
the new, extensive Note [PrimOp can_fail and has_side_effects]
in PrimoOp.

When discarding a case with unused binders, in the lifted-type
case it's definitely ok if the scrutinee terminates; previously
we were checking exprOkForSpeculation, which is significantly
worse.

So I wanted a new function CoreUtils.exprCertainlyTerminates.
In doing this I ended up with a significant refactoring in
CoreUtils.  The new structure has quite a lot of nice sharing:

    exprIsCheap             = exprIsCheap' isHNFApp
    exprIsExpandable        = exprIsCheap' isConLikeApp

    exprIsHNF               = exprIsHNFlike isHNFApp
    exprIsConLike           = exprIsHNFlike isConLikeApp
    exprCertainlyTerminates = exprIsHNFlike isTerminatingApp
compiler/coreSyn/CoreArity.lhs
compiler/coreSyn/CoreUtils.lhs
compiler/main/StaticFlagParser.hs
compiler/main/StaticFlags.hs
compiler/prelude/PrimOp.lhs
compiler/simplCore/FloatIn.lhs
compiler/simplCore/OccurAnal.lhs
compiler/simplCore/SimplUtils.lhs
compiler/simplCore/Simplify.lhs