-qinline

Category

Optimization and tuning

Pragma equivalent

None.

Purpose

Attempts to inline functions instead of generating calls to those functions, for improved performance.

Note:
  • -qinline replaces -Q and its suboptions.
  • -Q, -Q!, -Q=threshold, -Q+name, and -Q-name are all deprecated options and suboptions.
  • -qipa=inline|noinline and -qipa=inline suboptions auto, noauto, limit, and threshold are deprecated. -qinline replaces them all.

C++ only Specifying -qinline enables automatic inlining by the compiler front end. Specifying -qinline with -O provides additional inlining by enabling inlining by the low-level optimizer. In both cases, the compiler attempts to inline all functions, in addition to those defined inside a class declaration or explicitly marked with the inline specifier.

C only You must specify a minimum optimization level of -O2 along with -qinline to enable inlining of functions, including those declared with the inline specifier. You can also use the -qinline option to specify restrictions on the functions that should or should not be inlined.

In all cases where -qinline is in effect, the compiler uses heuristics to determine whether inlining a specific function will result in a performance benefit. That is, whether a function is appropriate for inlining is subject to limits on the number of inlined calls and the amount of code size increase as a result. Therefore, simply enabling inlining does not guarantee that a given function will be inlined.

Specifying -qnoinline disables all inlining, including that performed by the high-level optimizer with the -qipa option, and functions declared explicitly as inline.

Syntax

Read syntax diagramSkip visual syntax diagram
   .- -qnoinline------------------------------.   
>>-+- -qinline-+----------------------------+-+----------------><
               |   .-:--------------------. |     
               |   V .-auto-------------. | |     
               +-=---+-noauto-----------+-+-+     
               |     +-level--=--number-+   |     
               |     '-autothreshold----'   |     
               |         .-:-------------.  |     
               |         V               |  |     
               '-+- + +----function_name-+--'     
                 '- - '                           

Defaults

  • -qnoinline
  • At an optimization level of -O0, the default is -qinline=noauto
  • At optimization levels of -O2 and higher, the default is -qinline=auto
  • -qinline=auto:level=5 is the default suboption of -qinline

Parameters

noauto | auto
Enables or disables automatic inlining.
level=number
Provides guidance to the compiler about the relative value of inlining. The values you specify for number must be positive integers between 0 and 10 inclusive. The default value for number is 5. If you specify a value less than 5, it implies less inlining. A value greater than 5 implies more inlining than the default.
C only autothreshold
Represents the number of executable statements in a function. The number of executable statements in a function must be fewer than or equal to autothreshold for it to be considered for inlining. The value you specify for autothreshold must be a positive integer. The default value for autothreshold is 20. If you specify a value of 0, no functions are inlined. As you can see in the following example:
increment()
{
  int a, b, i;
   for (i=0; i<10; i++) /* statement 1 */
   { 
      a=i;              /* statement 2 */ 
      b=i;              /* statement 3 */
   } 
}
function_name
Indicates whether the named function should (after +) or should not (after -) be inlined. For example, -qinline+foo:bar indicates that procedures foo and bar must be inlined, and -qinline-bar indicates that the procedure bar must not be inlined. You cannot mix the "+" and "-" suboptions with each other or with other -qinline suboptions. For example, -qinline+foo-bar and -qinline=level=5+foo are invalid suboption combinations. However, you can use -qinline separately to achieve the desired effect. For example, -qinline+foo:baz -qinline-bar -qinline=noauto:level=7.

Usage

To maximize inlining, specify optimization (-O) and also specify the appropriate -qinline options.

Because inlining does not always improve runtime performance, you should test the effects of this option on your code. Do not attempt to inline recursive or mutually recursive functions.

If you specify the -g option to generate debug information, inlining may be suppressed.

Predefined macros

None.

Examples

To compile myprogram.c so that no functions are inlined, enter:
xlc myprogram.c -O2 -qnoinline
Assuming you have functions salary, taxes, expenses, and benefits, to compile myprogram.c so that the compiler tries to inline these functions, you enter:
xlc myprogram.c -O2 -qinline+salary:taxes:expenses:benefits
If you do not want the functions salary, taxes, expenses, and benefits to be inlined when you compile myprogram.cmyprogram.f, you enter:
xlc myprogram.c -O2 -qinline-salary:taxes:expenses:benefits
C only In general, you can turn off automatic inlining and request that specific functions be inlined by naming them with the + form:
-O2 -qinline=noauto -qinline+salary:taxes:benefits
This causes only the functions named salary, taxes, or benefits to be inlined, if possible, and no others.
If you want to use the automatic inlining function, you use the auto suboption:
-O2 -qinline=auto
You can specify an inlining level between 6 and 10 to perform more aggressive automatic inlining. For example:
-O2 -qinline=auto:level=7
If automatic inlining is already enabled by default and you want to specify an inlining level (For example: 7), you enter:
-O2 -qinline=level=7

Related information