A function call as the last action of function body can be optimized by overwriting the stack frame of the caller. The callee returns directly to the caller of its caller. The gain of this program optimization is the stack space that is saved and a few instructions for restoring the return address and jumping to it. It can be as simple as replacing the call and return instructions with a jump instruction. Tail recursion elimination is a special case.

-- EelcoVisser - 06 Dec 2001


CategoryOptimization

Revision: r1.2 - 07 Dec 2001 - 06:02 - MikeVanEmmerik
Transform > ProgramOptimization > TailCallElimination
Copyright © 1999-2020 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback