6.7.7 Options for Controlling Optimization

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

Table 6-16. General Optimization Options
Option

(links to explanatory section)

Controls
-O0Disabling of all optimizations.
-O

-O1

Optimization level 1.
-O2Optimization level 2.
-O3Speed-orientated optimizations.
-Og

Less optimizations for better debugging.

-OsSize-orientated optimizations.
-madj-exiting-edge-probRearrangement of basic blocks within loops.
-falign-functions[=n]

-f[no-]align-functions

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

-f[no-]align-labels

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

-f[no-]align-loops

Alignment of loops.
-mauto-indexingSubstitution of load-then-increment sequences.
-f[no-]caller-savesAllocation into registers clobbered by function calls.
-f[no-]cse-follow-jumpsCustomization of common subexpression elimination optimizations.
-f[no-]cse-skip-blocksCustomization of common subexpression elimination optimizations.
-f[no-]data-sectionsPlacement of objects into a section in the output file.
-f[no-]defer-popWhen arguments to function calls are popped.
-f[no-]expensive-optimizationsMinor optimizations that are relatively expensive.
-f[no-]fat-lto-objectsGeneration of fat object files.
-f[no-]function-csePlacement of function addresses.
-f[no-]function-sectionsPlacement of functions into a section in the output file.
-f[no-]gcseThe global common subexpression elimination pass.
-f[no-]gcse-lmCustomization of common subexpression elimination dealing with loads.
-f[no-]gcse-smCustomization of common subexpression elimination dealing with stores.
-f[no-]inlineControls processing of functions marked with theinline keyword.
-f[no-]inline-functionsIntegratation of all simple functions into their callers.
-f[no-]inline-limit=n The size limit for inlining functions.
-finline-small-functionsIntegratation of all simple functions into their callers.
-f[no-]keep-inline-functionsOutput of a separate run-time-callable version of inlined functions.
-f[no-]keep-static-constsOutput of static const objects.
-mloop-rename-registersReallocation of values within loops to low-numbered registers.
-f[no-]ltoThe standard link-time optimizer.
-flto-partition=algorithmSelection of the link-time optimizer algorithm used to partition object files.
-f[no-]omit-frame-pointerReservation of the Frame Pointer in a register for functions that don't need one.
-f[no-]optimize-sibling-callsOptimization of sibling and tail recursive calls.
-m[no-]paProcedural Abstraction optimizations.
-f[no-]peel-loopsReconfiguration of loops in the source code.
-f[no-]peephole

-f[no-]peephole2

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

-f[no-]schedule-insns2

Reordering instructions to eliminate instruction stalls.
-f[no-]strength-reduceLegacy Option and is ignored.
-f[no-]strict-aliasingAssumption of the strictest aliasing rules applicable to the language being compiled.
-mthumb2-align-loopAlignment of loops to avoid pipeline reloads.
-f[no-]thread-jumpsJump-to-branch optimizations.
-f[no-]toplevel-reorderReordering of top-level functions, variables, and asm statements.
-f[no-]tracerTail duplication.
-ftree-vrpPerform value range propagation.
-ftrivial-auto-var-init=choiceInitialize automatic variables that have not been explicitly initialized in the source code
-f[no-]unroll-loops

-f[no-]unroll-all-loops

Loop unrolling.
-f[no-]use-linker-pluginUse of a linker plugin during link-time optimization.
-fzero-call-used-regs=choiceOverwriting "call-used" registers associated with functions when they return