## Optimization levels ## One of these needs to be specified for enable the use of optimization flags and parameters optimization_level "-" c (O2, O3) march "-march=" c (native) ## -O3 # When -fgcse-after-reload is enabled, a redundant load elimination pass is performed after reload. The purpose of this pass is to clean up redundant spilling. fgcse_after_reload "-" c (fno-gcse-after-reload, fgcse-after-reload) # Consider all functions for inlining, even if they are not declared inline. The compiler heuristically decides which functions are worth integrating in this way. If all calls to a given function are integrated, and the function is declared static, then the function is normally not output as assembler code in its own right. Enabled at level -O3. finline_functions "-" c (fno-inline-functions, finline-functions) # Perform function cloning to make interprocedural constant propagation stronger. When enabled, interprocedural constant propagation performs function cloning when externally visible function can be called with constant arguments. Because this optimization can create multiple copies of functions, it may significantly increase code size (see --param ipcp-unit-growth=value). This flag is enabled by default at -O3. fipa_cp_clone "-" c (fno-ipa-cp-clone, fipa-cp-clone) floop_interchange "-" c (fno-loop-interchange, floop-interchange) floop_unroll_and_jam "-" c (fno-loop-unroll-and-jam, floop-unroll-and-jam) # Peels loops for which there is enough information that they do not roll much (from profile feedback). It also turns on complete loop peeling (i.e. complete removal of loops with small constant number of iterations). Enabled with -O3 and/or -fprofile-use. fpeel_loops "-" c (fno-peel-loops, fpeel-loops) #Perform predictive commoning optimization, i.e., reusing computations (especially memory loads and stores) performed in previous iterations of loops. This option is enabled at level -O3. fpredictive_commoning "-" c (fno-predictive-commoning, fpredictive-commoning) # Split a loop into two if it contains a condition that's always true for one side of the iteration space and false for the other. fsplit_loops "-" c (fno-split-loops, fsplit-loops) # Split paths leading to loop backedges. This can improve dead code elimination and common subexpression elimination. This is enabled by default at -O2 and above. fsplit_paths "-" c (fno-split-paths, fsplit-paths) # Perform loop distribution. This flag can improve cache performance on big loop bodies and allow further loop optimizations, like parallelization or vectorization, to take place. ftree_loop_distribution "-" c (fno-tree-loop-distribution, ftree-loop-distribution) # Perform loop distribution of patterns that can be code generated with calls to a library. This flag is enabled by default at -O3. #This pass distributes the initialization loops and generates a call to memset zero. ftree_loop_distribute_patterns "-" c (fno-tree-loop-distribute-patterns, ftree-loop-distribute-patterns) # Make partial redundancy elimination (PRE) more aggressive. This flag is enabled by default at -O3. ftree_partial_pre "-" c (fno-tree-partial-pre,ftree-partial-pre) # Move branches with loop invariant conditions out of the loop, with duplicates of the loop on both branches (modified according to result of the condition). funswitch_loops "-" c (fno-unswitch-loops, funswitch-loops) # Alter the cost model used for vectorization. The model argument should be unlimited, dynamic or cheap. With the unlimited model the vectorized code-path is assumed to be profitable while with the dynamic model a runtime check guards the vectorized code-path to enable it only for iteration counts that will likely execute faster than when executing the original scalar loop. The cheap model disables vectorization of loops where doing so would be cost prohibitive for example due to required runtime checks for data dependence or alignment but otherwise is equal to the dynamic model. The default cost model depends on other optimization flags and is either dynamic or cheap. fvect_cost_model "-fvect-cost-model=" c (unlimited, dynamic, cheap) # Perform vectorization on trees. This flag enables -ftree-loop-vectorize and -ftree-slp-vectorize if not explicitly specified. ftree_vectorize "-" c (fno-tree-vectorize, ftree-vectorize) # Perform basic block vectorization on trees. This flag is enabled by default at -O3 and when -ftree-vectorize is enabled. ftree_slp_vectorize "-" c (fno-tree-slp-vectorize, ftree-slp-vectorize) | ftree_vectorize %in% c("fno-tree-vectorize") # Perform loop vectorization on trees. This flag is enabled by default at -O3 and when -ftree-vectorize is enabled. ftree_loop_vectorize "-" c (fno-tree-loop-vectorize, ftree-loop-vectorize) | ftree_vectorize %in% c("fno-tree-vectorize") ## LTO # Assume that the current compilation unit represents the whole program being compiled. All public functions and variables with the exception of main and those merged by attribute externally_visible become static functions and in effect are optimized more aggressively by interprocedural optimizers. #This option should not be used in combination with -flto. Instead relying on a linker plugin should provide safer and more precise information. fwhole_program "-" c (fno-whole-program, fwhole-program) | flto %in% c("fno-lto") flto "-" c ("flto","fno-lto") # Enables the use of a linker plugin during link-time optimization. This option relies on plugin support in the linker, which is available in gold or in GNU ld 2.21 or newer. #This option enables the extraction of object files with GIMPLE bytecode out of library archives. This improves the quality of optimization by exposing more code to the link-time optimizer. This information specifies what symbols can be accessed externally (by non-LTO object or during dynamic linking). Resulting code quality improvements on binaries (and shared libraries that use hidden visibility) are similar to -fwhole-program. See -flto for a description of the effect of this flag and how to use it. # #This option is enabled by default when LTO support in GCC is enabled and GCC was configured for use with a linker supporting plugins (GNU ld 2.21 or newer or gold). fuse_linker_plugin "-" c (fno-use-linker-plugin, fuse-linker-plugin) | flto %in% c("flto") ## graphite fgraphite_identity "-" c (fno-graphite-identity,fgraphite-identity) floop_nest_optimize "-" c (fno-loop-nest-optimize,floop-nest-optimize) ## unsafe math ffast_math "-" c (fno-fast-math,ffast-math) ## clear linux fcommon "-" c (fno-common,fcommon) # Perform interprocedural pointer analysis and interprocedural modification and reference analysis. This option can cause excessive memory and compile-time usage on large compilation units. It is not enabled by default at any optimization level. fipa_pta "-" c (fno-ipa-pta, fipa-pta) # Some object formats, like ELF, allow interposing of symbols by the dynamic linker. This means that for symbols exported from the DSO, the compiler cannot perform interprocedural propagation, inlining and other optimizations in anticipation that the function or variable in question may change. While this feature is useful, for example, to rewrite memory allocation functions by a debugging implementation, it is expensive in the terms of code quality. With -fno-semantic-interposition the compiler assumes that if interposition happens for functions the overwriting function will have precisely the same semantics (and side effects). Similarly if interposition happens for variables, the constructor of the variable will be the same. The flag has no effect for functions explicitly declared inline (where it is never allowed for interposition to change semantics) and for symbols explicitly declared weak. fsemantic_interposition "-" c (fno-semantic-interposition, fsemantic-interposition) # Align the start of functions to the next power-of-two greater than n, skipping up to n bytes. For instance, -falign-functions=32 aligns functions to the next 32-byte boundary, but -falign-functions=24 aligns to the next 32-byte boundary only if this can be done by skipping 23 bytes or less. # -fno-align-functions and -falign-functions=1 are equivalent and mean that functions are not aligned. # Some assemblers only support this flag when n is a power of two; in that case, it is rounded up. # If n is not specified or is zero, use a machine-dependent default. # Enabled at levels -O2, -O3. falign_functions "-falign-functions=" o (0,1,2,4,16,24,32,64) #0: machine dependent, 1:fno-align-functions ## not at any # When -fgcse-sm is enabled, a store motion pass is run after global common subexpression elimination. This pass attempts to move stores out of loops. When used in conjunction with -fgcse-lm, loops containing a load/store sequence can be changed to a load before the loop and a store after the loop. Not enabled at any optimization level. fgcse_sm "-" c (fno-gcse-sm, fgcse-sm) # When -fgcse-las is enabled, the global common subexpression elimination pass eliminates redundant loads that come after stores to the same memory location (both partial and full redundancies). Not enabled at any optimization level. fgcse_las "-" c (fno-gcse-las, fgcse-las) #Use IRA to evaluate register pressure in loops for decisions to move loop invariants. This option usually results in generation of faster and smaller code on machines with large register files (>= 32 registers), but it can slow the compiler down. This option is enabled at level -O3 for some targets. fira_loop_pressure "-" c (fno-ira-loop-pressure,fira-loop-pressure) # If this option is enabled, the compiler tries to avoid unnecessarily overaligning functions. It attempts to instruct the assembler to align by the amount specified by -falign-functions, but not to skip more bytes than the size of the function. flimit_function_alignment "-" c (fno-limit-function-alignment, flimit-function-alignment) # Attempt to decrease register pressure through register live range shrinkage. This is helpful for fast processors with small or moderate size register sets. flive_range_shrinkage "-" c (fno-live-range-shrinkage, flive-range-shrinkage) # Enable register pressure sensitive insn scheduling before register allocation. This only makes sense when scheduling before register allocation is enabled, i.e. with -fschedule-insns or at -O2 or higher. Usage of this option can improve the generated code and decrease its size by preventing register pressure increase above the number of available hard registers and subsequent spills in register allocation. fsched_pressure "-" c (fno-sched-pressure,fsched-pressure) #| fschedule_insns %in% c("fschedule-insns") # Allow speculative motion of some load instructions. This only makes sense when scheduling before register allocation, i.e. with -fschedule-insns or at -O2 or higher. fsched_spec_load "-" c (fno-sched-spec-load, fsched-spec-load) #| fschedule_insns %in% c("fschedule-insns") # When scheduling after register allocation, use superblock scheduling. This allows motion across basic block boundaries, resulting in faster schedules. This option is experimental, as not all machine descriptions used by GCC model the CPU closely enough to avoid unreliable results from the algorithm. This only makes sense when scheduling after register allocation, i.e. with -fschedule-insns2 or at -O2 or higher. #fsched2_use_superblocks "-" c (fno-sched2-use-superblocks, fsched2-use-superblocks) #| fschedule_insns2 %in% c("fschedule-insns2") ## unroll # Unroll loops whose number of iterations can be determined at compile time or upon entry to the loop. -funroll-loops implies -frerun-cse-after-loop, -fweb and -frename-registers. It also turns on complete loop peeling (i.e. complete removal of loops with a small constant number of iterations). This option makes code larger, and may or may not make it run faster. Enabled with -fprofile-use. funroll_loops "-" c (fno-unroll-loops, funroll-loops) # Unroll all loops, even if their number of iterations is uncertain when the loop is entered. This usually makes programs run more slowly. -funroll-all-loops implies the same options as -funroll-loops. funroll_all_loops "-" c (fno-unroll-all-loops, funroll-all-loops) # Constructs webs as commonly used for register allocation purposes and assign each web individual pseudo register. This allows the register allocation pass to operate on pseudos directly, but also strengthens several other optimization passes, such as CSE, loop optimizer and trivial dead code remover. It can, however, make debugging impossible, since variables no longer stay in a “home register”. # Enabled by default with -funroll-loops. fweb "-" c (fno-web, fweb) | funroll_loops %in% c("fno-unroll_loops") & funroll_all_loops %in% c("fno-unroll-all-loops") frename_registers "-" c (fno-rename-registers, frename-registers) | funroll_loops %in% c("fno-unroll_loops") & funroll_all_loops %in% c("fno-unroll-all-loops") # With this option, the compiler creates multiple copies of some local variables when unrolling a loop, which can result in superior code. fvariable_expansion_in_unroller "-" c (fno-variable-expansion-in-unroller, fvariable-expansion-in-unroller)