
#15560: Full laziness destroys opportunities for join points -------------------------------------+------------------------------------- Reporter: AndreasK | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.4.3 (CodeGen) | Resolution: | Keywords: JoinPoints Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #14287 #13286 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj):
Ideally we would combine the checks for all branches into a single one to begin with.
Do you mean that in {{{ case x of True -> e1 False -> e2 }}} instead of a heap-check at the start of `e1` and another at the start of `e2`, we could have a single one before the case? No, we can't do this: evaluating `x` might force a thunk, and hence allocate an arbitrary amount of stuff. If the `case` is strutinising an unlifted type (which does not require evaluating) then yes it's different, and indeed in that case we sometimes ''do'' move the heap check up. See the long `Note [Compiling case expressions]` in `StgCmmExpr.hs`. (Another possibility that looks unattractive, and that I have not explored: put the heap check after returning from evaluating `x` but before doing the case-analysis to decide which branch to take. That might reduce code size, but would never eliminate a heap check altogether; indeed it might put one in the code path that was not there before, for a branch that did not allocate at all.) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15560#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler