On Jan 12, 2009, at 12:47 PM, Max Bolingbroke wrote:
2009/1/12 Jan-Willem Maessen <jmaes...@alum.mit.edu>:
On Jan 12, 2009, at 9:01 AM, Duncan Coutts wrote:
No because the current definition are recursive and ghc cannot
inline
recursive functions.
....
Then the map can be inlined at the call site and the 'f' inlined
into
the body of 'go'.
This seems like exactly the sort of mechanical transformation that
computers
do quickly and accurately, and humans get wrong. Surely it
wouldn't be that
hard for GHC to transform self recursion in this way (possibly
subject to
the condition that the result be worth inlining)?
GHC should indeed be doing so. I'm working (on and off) to work out
some suitable heuristics and put the transformation into ghc -O2.
There are a few wrinkles that still need sorting out, but preliminary
indications are that it decreases the runtime of our standard
benchmark suite, nofib, by 12% or so.
This is excellent news, quite apart from Don's observation that it
isn't particularly relevant for map (where we are essentially using
RULES to instantiate an alternative definition in terms of foldr/
build, if I understand his message rightly). Self recursion is abut
so much more than map!
-Jan
Cheers,
Max
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe