[LLVMdev] Does LLVM optimize recursive call?
dblaikie at gmail.com
Tue Oct 2 23:53:36 PDT 2012
On Tue, Oct 2, 2012 at 11:44 PM, Journeyer J. Joh
<oosaprogrammer at gmail.com> wrote:
> Hi list,
> I have a simple question about LLVM.
> I learned that we need to use iterations than recursions in C programming.
> That is because recursion is expensive. It can easily consume out all
> the stack given to a program. And the call/return consumes time much
> But I've read a sentence that nowadays compilers can optimize
> recursions in C or whatever languages not to consume heavy stack and
> I wonder what kind of optimization this is and if LLVM support this
> kind of optimization.
> I am not a compiler expert. Please consider this. ^^;
The short answer is: sometimes.
Some recursive code may be transformed into something similar to a
loop, but sometimes the compiler won't be able to figure it out &
it'll remain recursive.
More information about the llvm-dev