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-14. Optimization Options
OptionEditionControls
-O0AllDo not optimize.
-O

-O1

AllOptimization level 1.
-O2AllOptimization level 2.
-O3PRO onlySpeed-orientated optimizations.
-OsPRO onlySize-orientated optimizations.
-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.
-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.
-ffat-lto-objectsAllRequests that the compiler generate fat object files.
-f[no-]function-cseAllPlacement of function addresses.
-f[no-]function-sectionsAllPlacement of functions into a 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-]inline-functionsAllIntegration of all simple functions into their callers.
-f[no-]inline-limit=n AllThe size limit for inlining functions.
-finline-small-functionsAllIntegration 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.
-f[no-]ltoPRO onlyThe standard link-time optimizer.
-flto-partition=algorithmPRO onlyThe 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-register-move

-f[no-]regmove

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

-f[no-]schedule-insns2

AllReordering instructions to eliminate instruction stalls.
-f[no-]strength-reduceAllLoop strength reduction and elimination of iteration variables.
-f[no-]strict-aliasingAllAssumption of the strictest aliasing rules applicable to the language being compiled.
-f[no-]thread-jumpsAllJump-to-branch optimizations.
-f[no-]toplevel-reorderAllReordering of top-level functions, variables, and asm statements.
-ftracerAllPerform tail duplication.
-f[no-]unroll-loops

-f[no-]unroll-all-loops

AllLoop unrolling.
-fuse-linker-pluginAllEnable use of a linker plugin during link-time optimization plugin.
-f[no-]whole-programPRO onlyMore aggressive interprocedural optimizations.