
#14067: Static Argument Transformation for tail-recursive functions -------------------------------------+------------------------------------- Reporter: nomeata | Owner: mpickering Type: task | 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: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Description changed by nomeata: Old description:
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.
New description: In #13966 it was determined that having a variant of the Static Argument Transformation (StaticArgumentTransformation) pass that would specifically work on recursive join points, would be beneficial. This ticket tracks this task. Consider {{{ joinrec $j x y = case y of A -> $j x y' B -> e2 x C -> e3 in $j foo bar }}} Here the first argument to `$j` is "static"; that is, the same in every call. So we can transform like this {{{ joinrec $j y = case y of A -> $j y' B -> e2 foo C -> e3 in $j bar }}} Note that `x` isn't passed around in every iteration any more. -- -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14067#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler