[GHC] #14068: Turn tail-recursive functions into recursive jointpoints

GHC ghc-devs at haskell.org
Tue Aug 1 07:18:12 UTC 2017


#14068: Turn tail-recursive functions into recursive jointpoints
-------------------------------------+-------------------------------------
        Reporter:  nomeata           |                Owner:  mpickering
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  8.0.1
      Resolution:                    |             Keywords:
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:                    |
-------------------------------------+-------------------------------------

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.
>
> This came up in #13966, and might go well with #14067.

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].

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

 It might work well with #13051.

--

Comment (by simonpj):

 This is a dup of

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


More information about the ghc-tickets mailing list