Skip to content

Recognize when inlining would create a join point

This discussion revolved around a program that runs 10x faster under ghci.

One way to solve this is to remove a superfluous inline pragma which allows the following transformation to happen:

letrec {
f a = case e of {
    p1 -> f a';
    p2 -> (# l, r #);
}} in case f e2 of { (# l, r #) -> e3; }

into

joinrec {
f a = case e of {
    p1 -> jump f a';
    p2 -> e3;
}} in jump f e2

More generally a recursive let binding that is called exactly once from the outside. If all recursive calls are tail calls and the outside one isn't then we could safely replace the call with the binding and end up with join points. In this case it means a 10x speedup so it might be worth doing generally.

letrec { fi = ei; } in ... (fj e) ... => ... (joinrec { fi = ei; } in jump fj e) ...

Self contained example

Edited by ersetzen
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information