[GHC] #14067: Static Argument Transformation for tail-recursive functions

GHC ghc-devs at haskell.org
Mon Jul 31 17:02:05 UTC 2017


#14067: Static Argument Transformation for tail-recursive functions
-------------------------------------+-------------------------------------
           Reporter:  nomeata        |             Owner:  (none)
               Type:  task           |            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:
-------------------------------------+-------------------------------------
 In #13966 it was determined that having a variant of the Static Argument
 Transformation (StaticArgumentTransformation)  pass that would
 specifically look for tail-recursive functions, and turn them into
 recursive join points, would be beneficial. This ticket tracks this task.

 Consider

 {{{
 f x y = case y of
           A -> f x y'
           B -> e2
           C -> e3
 }}}

 Here the first argument to f is "static"; that is, the same in every call.
 So we can transform like this

 {{{
 f x y = joinrec $j y = case y of
                           A -> $j y'
                           B -> e2
                           C -> e3
         in $j y

 }}}

 Note that `x` isn't passed around in every iteration.

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


More information about the ghc-tickets mailing list