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.