5.7.7 Options for Controlling Optimization

The options tabulated below control compiler optimizations and are described in the sections that follow.

Use of an option is permitted and has an effect with an unlicensed compiler (Free edition) if that option is enabled by default when using optimization level 2 or lower. Any form of option that disables an optimization is available unconditionally.

Table 5-15. General Optimization Options
Option

(links to explanatory section)

EditionControls
-O0AllDisabling of all optimizations.
-O

-O1

AllOptimization level 1.
-O2AllOptimization level 2.
-O3PRO onlySpeed-orientated optimizations.
-Og

All

Less optimizations for better debugging.

-OsPRO onlySize-orientated optimizations.
-madj-exiting-edge-prob All Rearrangement of basic blocks within loops.
-falign-functions[=n]

-f[no-]align-functions

AllAlignment of the start of functions.
-falign-labels[=n]

-f[no-]align-labels

AllAlignment of all branch targets.
-falign-loops[=n]

-f[no-]align-loops

AllAlignment of loops.
-mauto-indexing All Substitution of load-then-increment sequences.
-f[no-]caller-savesAllAllocation into registers clobbered by function calls.
-f[no-]cse-follow-jumpsAllCustomization of common subexpression elimination optimizations.
-f[no-]cse-skip-blocksAllCustomization of common subexpression elimination optimizations.
-f[no-]data-sectionsAllPlacement of objects into a section in the output file.
-f[no-]defer-popAllWhen arguments to function calls are popped.
-f[no-]expensive-optimizationsAllMinor optimizations that are relatively expensive.
-f[no-]fat-lto-objects All Generation of fat object files.
-f[no-]function-cseAllPlacement of function addresses.
-f[no-]function-sectionsAllPlacement of functions intoa section in the output file.
-f[no-]gcseAllThe global common subexpression elimination pass.
-f[no-]gcse-lmAllCustomization of common subexpression elimination dealing with loads.
-f[no-]gcse-smAllCustomization of common subexpression elimination dealing with stores.
-f[no-]inlineAllControls processing of functions marked with theinline keyword.
-f[no-]inline-functionsAllIntegratation of all simple functions into their callers.
-f[no-]inline-limit=n AllThe size limit for inlining functions.
-finline-small-functions All Integratation of all simple functions into their callers.
-f[no-]keep-inline-functionsAllOutput of a separate run-time-callable version of inlined functions.
-f[no-]keep-static-constsAllOutput of static const objects.
-mloop-rename-registers All Reallocation of values within loops to low-numbered registers.
-f[no-]ltoPRO onlyThe standard link-time optimizer.
-flto-partition=algorithm PRO only Selection of the link-time optimizer algorithm used to partition object files.
-f[no-]omit-frame-pointerAllReservation of the Frame Pointer in a register for functions that don't need one.
-f[no-]optimize-sibling-callsAllOptimization of sibling and tail recursive calls.
-m[no-]paPROProcedural Abstraction optimizations.
-f[no-]peel-loops All Reconfiguration of loops in the source code.
-f[no-]peephole

-f[no-]peephole2

AllMachine-specific peephole optimizations.
-f[no-]rename-registersAllUse of free registers to avoid false dependencies in scheduled code.
-f[no-]rerun-cse-after-loopAllWhen common subexpression elimination optimizations should be performed.
-f[no-]rerun-loop-optAllLegacy option and is ignored.
-f[no-]schedule-insns

-f[no-]schedule-insns2

AllReordering instructions to eliminate instruction stalls.
-f[no-]strength-reduceAllLegacy Option and is ignored.
-f[no-]strict-aliasingAllAssumption of the strictest aliasing rules applicable to the language being compiled.
-mthumb2-align-loop All Alignment of loops to avoid pipeline reloads.
-f[no-]thread-jumpsAllJump-to-branch optimizations.
-f[no-]toplevel-reorderAllReordering of top-level functions, variables, and asm statements.
-f[no-]tracer All Tail duplication.
-f[no-]unroll-loops

-f[no-]unroll-all-loops

AllLoop unrolling.
-f[no-]use-linker-plugin All Use of a linker plugin during link-time optimization.