[GHC] #14068: Loopification using join points

GHC ghc-devs at haskell.org
Tue Aug 1 07:24:09 UTC 2017


#14068: Loopification using join points
-------------------------------------+-------------------------------------
        Reporter:  nomeata           |                Owner:  mpickering
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  8.0.1
      Resolution:                    |             Keywords:  JoinPoints
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:  #13966 #14067     |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------
Description changed by simonpj:

Old description:

> The function
> {{{
> let f x y = case y of
>               A -> f x' y'
>               B -> e2
>               C -> e3
> in g f
> }}}
> is not turned into a recursive join point, because the call to `f` is not
> in tail call position. But the recursive calls are, and these matter
> performance-wise! Hence, it would be beneficial to turn this into
> {{{
> let f x y = joinrec $j x y = case x y of
>                               A -> $j x' y'
>                               B -> e2
>                               C -> e3
>             in $j x y
> in g f
> }}}
>
> This has the additional effect that now `f` is no longer recursive and
> may get inlined.
>
> The idea is described under "New idea: use join points" in
> [wiki:Commentary/Compiler/Loopification].
>
> It came up in #13966, and might go well with #14067.
>
> It might work well with #13051, which Thomas Jakway is still thinking
> about.

New description:

 The function
 {{{
 let f x y = case y of
               A -> f x' y'
               B -> e2
               C -> e3
 in g f
 }}}
 is not turned into a recursive join point, because the call to `f` is not
 in tail call position. But the recursive calls are, and these matter
 performance-wise! Hence, it would be beneficial to turn this into
 {{{
 let f x y = joinrec $j x y = case x y of
                               A -> $j x' y'
                               B -> e2
                               C -> e3
             in $j x y
 in g f
 }}}

 This has the additional effect that now `f` is no longer recursive and may
 get inlined.

 The idea is described under "New idea: use join points" in
 [wiki:Commentary/Compiler/Loopification].

 Some notes:

 * We should to this both at top level and for nested definitions.

 * We can remove the "loopification" code from the code generator when this
 is done.

 * It came up in #13966, and might go well with #14067.

 * It might work well with #13051, which Thomas Jakway is still thinking
 about.

--

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


More information about the ghc-tickets mailing list