Optimization and tuning

The options in this category allow you to control the optimization and tuning process, which can improve the performance of your application at run time.

Remember that not all options benefit all applications. Trade-offs sometimes occur between an increase in compile time, a reduction in debugging capability, and the improvements that optimization can provide.

In addition to the option descriptions in this section, consult the XL C/C++ Optimization and Programming Guide for a details on the optimization and tuning process as well as writing optimization-friendly source code.
Table 1. Optimization and tuning options
Option name Description
-finline-functions (-qinline)

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

-fstrict-aliasing (-qalias=ansi), -qalias

Indicates whether a program contains certain categories of aliasing or does not conform to C/C++ standard aliasing rules. The compiler limits the scope of some optimizations when there is a possibility that different names are aliases for the same storage location.

-funroll-loops (-qunroll), -funroll-all-loops (-qunroll=yes)

Controls loop unrolling, for improved performance.

Equivalent pragma: #pragma unroll

-fvisibility (-qvisibility)

Specifies the visibility attribute for external linkage entities in object files. The external linkage entities have the visibility attribute that is specified by the -fvisibility option if they do not get visibility attributes from pragma directives, explicitly specified attributes, or propagation rules.

Equivalent pragma: #pragma GCC visibility push, #pragma GCC visibility pop

-mcpu (-qarch)

Specifies the processor architecture for which the code (instructions) should be generated.

-mtune (-qtune)

Tunes instruction selection, scheduling, and other architecture-dependent performance enhancements to run best on a specific hardware architecture. Allows specification of a target SMT mode to direct optimizations for best performance in that mode.

-O, -qoptimize

Specifies whether to optimize code during compilation and, if so, at which level.

-p, -pg, -qprofile

Prepares the object files produced by the compiler for profiling.

-qaggrcopy

Enables destructive copy operations for structures and unions.

-qcache

Specifies the cache configuration for a specific execution machine.

-qcompact

Avoids optimizations that increase code size.

-qdataimported, -qdatalocal, -qtocdata

Marks data as local or imported.

-qdirectstorage

Informs the compiler that a given compilation unit may reference write-through-enabled or cache-inhibited storage.

-qhot

Performs high-order loop analysis and transformations (HOT) during optimization.

Equivalent pragma: #pragma nosimd

-qignerrno

Allows the compiler to perform optimizations as if system calls would not modify errno.

-qipa

Enables or customizes a class of optimizations known as interprocedural analysis (IPA).

-qisolated_call

Specifies functions in the source file that have no side effects other than those implied by their parameters.

-qlibansi

Assumes that all functions with the name of an ANSI C library function are in fact the system functions.

-qmaxmem

Limits the amount of memory that the compiler allocates while performing specific, memory-intensive optimizations to the specified number of kilobytes.

-qpdf1, -qpdf2

Tunes optimizations through profile-directed feedback (PDF), where results from sample program execution are used to improve optimization near conditional branches and in frequently executed code sections.

-qprefetch

Inserts prefetch instructions automatically where there are opportunities to improve code performance.

-qshowpdf

When used with -qpdf1 and a minimum optimization level of -O2 at compile and link steps, creates a PDF map file that contains additional profiling information for all procedures in your application.

-qsimd

Controls whether the compiler can automatically take advantage of vector instructions for processors that support them.

Equivalent pragma: #pragma nosimd

-qsmallstack

Reduces the size of the stack frame.

-qstrict

Ensures that optimizations done by default at the -O3 and higher optimization levels, and, optionally at -O2, do not alter the semantics of a program.

-qstrict_induction

Prevents the compiler from performing induction (loop counter) variable optimizations. These optimizations may be unsafe (may alter the semantics of your program) when there are integer overflow operations involving the induction variables.

-qunwind

Specifies whether the call stack can be unwound by code looking through the saved registers on the stack.

The following options are supported by XL C/C++ for GCC compatibility. For details about these options, see the GNU Compiler Collection online documentation at http://gcc.gnu.org/onlinedocs/.
  • -isysroot
  • --sysroot
  • -isystem


Voice your opinion on getting help information Ask IBM compiler experts a technical question in the IBM XL compilers forum Reach out to us