Annotation for unfolding wanted
Claus Reinke
claus.reinke at talk21.com
Wed Aug 1 08:37:21 EDT 2007
>Some compilers unroll recursive functions by inlining them N times, for some fixed N (say 3 or so).
>This reduces the loop overheads. GHC doesn't do this, although it'd be nice, because it makes
>repeated traversals of the code, and it's hard to spot when the function has been unrolled 3 times
>and then stop. If you look at the code after unrolling 3 times, from scratch, there's another call
>just waiting to be inlined.
couldn't the number of unfoldings be encoded in the name of the function?
f x = if p x then x else f (g x)
f x = if p x then x else let x' = (g x) in if p x' then x' else f#1 (g x')
where f#1 would be f for all other purposes, but with one unfolding used up,
and N being the bound for the f#i.
claus
More information about the Glasgow-haskell-users
mailing list