Loopification using join points
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 Commentary/Compiler/Loopification.
- 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.
- Should fix #14287 too.
- See also ticket:14068#comment:140494 of #14620, for a wrinkle.