Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
Parallel Programming Guide for HP-UX Systems > Chapter 5 Loop and cross-module optimization features

Inlining within a single source file

» 

Technical documentation

Complete book in PDF
» Feedback
Content starts here

 » Table of Contents

 » Glossary

 » Index

Inlining substitutes selected function calls with copies of the function’s object code. Only functions that meet the optimizer’s criteria are inlined. Inlining may result in slightly larger executable files. However, this increase in size is offset by the elimination of time-consuming procedure calls and procedure returns.

At +O3, inlining is performed within a file; at +O4, it is performed across files. Inlining is affected by the +O[no]inline[=namelist] and +Oinline_budget=n command-line options. See Chapter 7 “Controlling optimization” for more information.

Example 5-2 Inlining within single source file

The following is an example of inlining at the source code level. Before inlining, the C source file looks like this:

/* Return the greatest common divisor of two positive integers,*/
/* int1 and int2, computed using Euclid's algorithm. (Return 0 */
/* if either is not positive.) */

int gcd(int int1,int int2)
{
int inttemp;

if ( (int1 <= 0) || (int2 <= 0) ) {
return(0);
}
do {
if (int1 < int2) {
inttemp = int1;
int1 = int2;
int2 = inttemp;
}
int1 = int1 - int2;
} while (int1 > 0);
return(int2);
}main()
{
int xval,yval,gcdxy;
.
. /* statements before call to gcd */
.
gcdxy = gcd(xval,yval);
.
. /* statements after call to gcd */
.
}

After inlining, main looks like this:

main()
{
int xval,yval,gcdxy;
.
. /* statements before inlined version of gcd */
.
{
int int1;
int int2; int1 = xval;
int2 = yval;
{
int inttemp; if ( (int1 <= 0) || (int2 <= 0) ){
gcdxy = (0);
goto AA003;
}
do {
if (int1 < int2){
inttemp = int1;
int1 = int2;
int2 = inttemp;
}
int1 = int1 - int2;
} while (int1 > 0);
gcdxy = (int2);
}
}
AA003 : ;
.
. /* statements after inlined version of gcd */
.
}
Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© Hewlett-Packard Development Company, L.P.