Criteria for Inline Function Expansion

While function inlining (function expansion) increases execution time by removing the runtime overhead of function calls, inlining can, in many cases, increase code size, code complexity, and compile times.

In the Intel compiler, inline function expansion typically favors relatively small user functions over functions that are relatively large; however, the compiler can inline functions only if the conditions in the three main components match the conditions listed below:

Selecting Routines for Inlining

If the minimum criteria identified are met, the compiler picks the routines whose inline expansions will provide the greatest benefit to program performance. This is done using the default heuristics. The inlining heuristics used by the compiler differ based on whether or not you use Profile-Guided Optimizations (PGO): -prof-use (Linux*) or /Qprof-use (Windows*).

When you use PGO with -ip or -ipo (Linux) or /Qip or /Qipo (Windows), the compiler uses the following heuristics:

Platform

Command

Linux

-Qoption,c,-ip_ninl_max_stats=n

Windows

/Qoption,c,-ip_ninl_max_stats=n

where n is a new value.

Note

There is a higher limit for functions declared by the user as inline or __inline.

See Using Qoption Specifiers and Profile-Guided Optimization Overview.

When you do not use PGO with -ip or -ipo (Linux) or /Qip or /Qipo (Windows), the compiler uses less aggressive inlining heuristics: it inlines a function if the inline expansion does not increase the size of the final program.

The compiler offers some alternatives to using the Qoption specifiers; see Developer Directed Inline Expansion of User Functions for a summary.

Inlining (Linux*)

If you do not use profile-guided optimizations with -ip or -ipo, the compiler uses less aggressive inlining heuristics:

PGO (Windows*)

The compiler uses characteristics of the source code to estimate which function calls are executed most frequently. It applies these estimates to the PGO-based heuristics described previously. The estimation of frequency, based on static characteristics of the source, is not always accurate. Hence, use of /Qip and /Qipo without PGO can result in longer compilation times and even slower application execution.