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 g.
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.
Change History (31)
Changed 9 years ago by simonpj
comment:11 Changed 6 years ago by igloo
- Milestone changed from 6.12.3 to 6.14.1
- Priority changed from normal to low
comment:21 Changed 4 years ago by igloo
- Milestone changed from 7.4.1 to 7.6.1
- Priority changed from low to normal