[LLVMdev] inlining of recursive functions
echristo at apple.com
Fri Oct 7 14:02:02 PDT 2011
On Oct 4, 2011, at 4:36 PM, Christophe Raffalli wrote:
> In lib/Analysis/InlineCost.cpp, inlining of recursive functions is
> disabled because it is
> like loop unrolling. But
> - I could not find a way to have loop unrolling do the job
> - In the context of functionnal languages (I am implementing one), inlining
> small recursive functions is often a great gain
> My question is what is the cleanest and simplest way to inline small
> recursive functions ?
> Just commenting out this test (which is probably not correct)
> gives on fibonacci (C code attached) on my intel dual core old mac :
> clang -O3 with inlining 0.16s
> gcc -O3 0.50s
> clang -O3 without inlining 1.20s
> fibonacci is really useless but if you look at OCaml or GHC libraries,
> you will find plenty of very small recursive functions on lists for
> instance (map, fold_left, ...).
> And the figure here should apply there to ... with probably a less
> dramatic effect in general.
It could, and having it turn on when you turn on loop unrolling or some
such might not be a bad idea. A lot of algorithms are recursive and the
code bloat from that sort of change could be significant.
Largely I'd want to see a wider range of tests before we can look at
turning it on in general. I haven't done them and can't recall when anyone
else did either.
Now, if code bloat isn't an issue we could turn it on - maybe at O3 or something.
More information about the llvm-dev