EasyManua.ls Logo

Intel i960 - Tail-Call Elimination

Intel i960
347 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
i960 Processor Compiler User's Guide
11-12
11
In the following example, the swap function switches two numbers. The
source text contains a function call:
void swap(x,y) /* function body */
int *x, *y;
{
int temp;
temp = *x; *x = *y; *y = temp;
}
main()
{
...
if (a > b) swap(&a, &b); /* function call */
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.

Table of Contents

Related product manuals