5.7.7 Options for Controlling Optimization

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

Table 5-15. Optimization Options
OptionControls
-O0Do not optimize.
-O

-O1

Optimization level 1.
-O2Optimization level 2.
-O3Speed-orientated optimizations.
-OsSize-orientated optimizations.
-f[no-]align-functions=nAlignment of the start of functions.
-f[no-]align-jumps=nAlignment of jump targets
-f[no-]align-labels=nAlignment of all branch targets.
-f[no-]align-loops=nAlignment of loops.
-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.
-ffat-lto-objectsRequests that the compiler generate 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.
-finlineInlining of functions marked with the inline specifier
-f[no-]inline-functionsIntegration of all simple functions into their callers.
-f[no-]inline-limit=n The size limit for inlining functions.
-finline-small-functionsIntegration 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.
-f[no-]ltoThe standard link-time optimizer.
-flto-partition=algorithmThe 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-register-move

-f[no-]regmove

Reassign of register numbers in move and other instructions.
-f[no-]optimize-sibling-callsOptimization of sibling and tail recursive calls.
-fpeel-loopsReconfigure 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-optHow often to run the loop optimizer.
-f[no-]schedule-insns

-f[no-]schedule-insns2

Reordering instructions to eliminate instruction stalls.
-f[no-]strength-reduceLoop strength reduction and elimination of iteration variables.
-f[no-]strict-aliasingAssumption of the strictest aliasing rules applicable to the language being compiled.
-f[no-]thread-jumpsJump-to-branch optimizations.
-f[no-]toplevel-reorderReordering of top-level functions, variables, and asm statements.
-ftracerPerform tail 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.
-fuse-linker-pluginEnable use of a linker plugin during link-time optimization plugin.
-f[no-]whole-programMore aggressive interprocedural optimizations.
-fzero-call-used-regs=choiceOverwriting "call-used" registers associated with functions when they return