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-13. General Optimization Options
Option

(links to explanatory section)

EditionControls
-O0AllDo not optimize.
-O

-O1

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

All

Less optimizations for better debugging.

-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.
-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.
-finlineAllControls 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.
-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.
-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-]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.
-f[no-]thread-jumpsAllJump-to-branch optimizations.
-f[no-]toplevel-reorderAllReordering of top-level functions, variables, and asm statements.
-f[no-]unroll-loops

-f[no-]unroll-all-loops

AllLoop unrolling.