
#13224: Rules and join points -------------------------------------+------------------------------------- Reporter: lukemaurer | Owner: lukemaurer Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Keywords: JoinPoints | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- From Note [Rules and join points] in `OccurAnal`: Things get fiddly with rules. Suppose we have: {{{ let j :: Int -> Int j y = 2 * y k :: Int -> Int -> Int {-# RULES "SPEC k 0" k 0 = j #-} k x y = x + 2 * y in ... }}} Now suppose that both j and k appear only as saturated tail calls in the body. Thus we would like to make them both join points. The rule complicates matters, though, as its RHS has an unapplied occurrence of j. //However//, if we were to eta-expand the rule, all would be well: {{{ {-# RULES "SPEC k 0" forall a. k 0 a = j a #-} }}} So conceivably we could notice that a potential join point would have an "undersaturated" rule and account for it. This would mean we could make something that's been specialised a join point, for instance. But local bindings are rarely specialised, and being overly cautious about rules only costs us anything when, for some `j`: * Before specialisation, `j` has non-tail calls, so it can't be a join point. * During specialisation, `j` gets specialised and thus acquires rules. * Sometime afterward, the non-tail calls to `j` disappear (as dead code, say), and so now `j` //could// become a join point. This appears to be very rare in practice. TODO Perhaps we should gather statistics to be sure. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13224 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler