[GHC] #13543: Improve demand analysis for join points

GHC ghc-devs at haskell.org
Fri Apr 7 12:33:19 UTC 2017


#13543: Improve demand analysis for join points
-------------------------------------+-------------------------------------
           Reporter:  simonpj        |             Owner:  (none)
               Type:  bug            |            Status:  new
           Priority:  normal         |         Milestone:
          Component:  Compiler       |           Version:  8.0.1
           Keywords:                 |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 Consider
 {{{
    g :: (Int,Int) -> Int
    g (p,q) = p+q

    f :: Int -> Int -> Int
    f x p = g (join j y = (p,y)
               in case x of
                    True  -> j 3
                    False -> j 4)
 }}}
 If `j` was a vanilla function definition, we'd analyse its body with
 `evalDmd`, and think that it was lazy in `p`.

 But for a join point we can do better.  We know that
 `j`'s body (if evaluated at all) will be evaluated with the demand that
 consumes the entire
 join-binding, in this case the argument demand from `g`.  Whizzo!  `g`
 evaluates both components of its arugment pair, so j is strict in `p`.

 So, when analysing a join point, we can analyse its body with the
 demand from the entire join-binding.  Another
 win for join points!

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13543>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list