#888: Implement the static argument transformation
-------------------------+--------------------------------------------------
Reporter: simonpj | Owner:
Type: task | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 6.4.2
Severity: normal | Keywords:
Os: Unknown | Difficulty: Unknown
Architecture: Unknown |
-------------------------+--------------------------------------------------
The Static Argument transformation optimises
{{{
f x y = ....f x' y...
}}}
into
{{{
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
[http://research.microsoft.com/%7Esimonpj/Papers/santos-thesis.ps.gz 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.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/888>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs