Implement the static argument transformation
|Reported by:||simonpj||Owned by:|
|Keywords:||Cc:||Bulat.Ziganshin@…, johan.tibell@…, hackage.haskell.org@…, reiner.pope@…, Jake.McArthur@…, choener@…, dterei, maoe|
|Type of failure:||None/Unknown||Test Case:||N/A|
|Related Tickets:||Differential Rev(s):|
The Static Argument transformation optimises
f x y = ....f x' y...
f x y = let g x = ....g x'... in g x
Instead of passing
y along unchanged, we make it into a free variable of a local function definition
Unfortunately, it's not always a win. Andre Santos gives a discussion, and quite a few numbers in his thesis.
But sometimes it is a pretty big win. Here's the example that recently motivated me, which Roman Leshchinskiy showed me. You need the attached file Stream.hs, and then try compiling
import Stream foo :: (a -> b) -> [a] -> [c] foo f = mapL f
Thus inspired, I think I have a set of criteria that would make the static arg transformation into a guaranteed win:
- there is only one (external) call to the function
- OR its RHS is small enough to inline
- OR it is marked INLINE (?)
So I'd like to try this idea out.