
#14137: Do more inlining into non-recursive join points -------------------------------------+------------------------------------- Reporter: simonpj | Owner: nomeata Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.2.1 Resolution: | Keywords: JoinPoints Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonpj):
Also, safe is recursive, so we don’t inline into it anyways.
Ah! Here is yet another place where join points are special. Consider {{{ join j = e in joinrec j2 x = ...j... }}} where there is just one occurrence of `j` in `j2`. Normally we'd be leery about inlining `j` under that `\x` because we might lose sharing. But nullary join points aren't thunks, so the situation is just as if we'd said {{{ join j _ = e in joinrec j2 x = ...(j ())... }}} when we'd cerainly inline it (via `preInlineUnconditinoally`). So let's make join points do that. In `preInlineUnconditionally`: {{{ | otherwise = case idOccInfo bndr of IAmDead -> True -- Happens in ((\x.1) v) occ@OneOcc { occ_one_br = True } -> try_once (occ_in_lam occ) (occ_int_cxt occ) _ -> False }}} In the `occ_one_br = True` alternative, add a guard {{{ | isJoinId bndr -> True -- New | otherwise -> try_Once (occ_in_lam occ) ... as before }}} That should be good for everyone! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14137#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler