Tail-Call Elimination - Intel i960 User Manual

Processor compiler
Hide thumbs Also See for i960:
Table of Contents

Advertisement

11
11-12
i960 Processor Compiler User's Guide
In the following example, the
source text contains a function call:
void swap(x,y)
int *x, *y;
{
int temp;
temp = *x; *x = *y; *y = temp;
}
main()
{
...
if (a > b) swap(&a, &b);
printf("The smaller number is %d\n",a);
...
}
After inline function expansion, the function body replaces the call:
main()
{
...
if (a > b)
{
int temp;
temp = a; a = b; b = temp;
}
printf("The smaller number is %d\n",a);
...
}

Tail-call Elimination

When a call directly precedes a return from a function, optimization can
sometimes replace the call with an unconditional branch to the called
function. This replacement saves execution time since a branch executes
faster than a call.
function switches two numbers. The
swap
/* function body */
/* function call */

Advertisement

Table of Contents
loading

Table of Contents