
31 Jul
2007
31 Jul
'07
10:51 a.m.
On Tue, 2007-07-31 at 10:36 -0400, Jan-Willem Maessen wrote:
I think what's meant here is translating something like this:
{-# INLINE f #-} f x y z = ... f x' y' z' ...
into this:
{-# INLINE f #-} f x y z = f' x y z where f' x y z = ... f' x' y' z' ...
That is, shoving (all of) the recursion in a level. Then inlining f results in a fresh loop, which presumably can be specialized or optimized in various ways.
This transformation is critical for performance of foldr and foldl('). The versions in GHC's libraries are manually written in the latter style. Duncan