📄 passes.texi
字号:
This pass attempts to change the name of compiler temporaries involved incopy operations such that SSA->normal can coalesce the copy away. When compilertemporaries are copies of user variables, it also renames the compilertemporary to the user variable resulting in better use of user symbols. It islocated in @file{tree-ssa-copyrename.c} and is described by@code{pass_copyrename}.@item PHI node optimizationsThis pass recognizes forms of PHI inputs that can be represented asconditional expressions and rewrites them into straight line code.It is located in @file{tree-ssa-phiopt.c} and is described by@code{pass_phiopt}.@item May-alias optimizationThis pass performs a flow sensitive SSA-based points-to analysis.The resulting may-alias, must-alias, and escape analysis informationis used to promote variables from in-memory addressable objects tonon-aliased variables that can be renamed into SSA form. We alsoupdate the @code{VDEF}/@code{VUSE} memory tags for non-renameableaggregates so that we get fewer false kills. The pass is locatedin @file{tree-ssa-alias.c} and is described by @code{pass_may_alias}.Interprocedural points-to information is located in@file{tree-ssa-structalias.c} and described by @code{pass_ipa_pta}.@item ProfilingThis pass rewrites the function in order to collect runtime blockand value profiling data. Such data may be fed back into the compileron a subsequent run so as to allow optimization based on expectedexecution frequencies. The pass is located in @file{predict.c} andis described by @code{pass_profile}.@item Lower complex arithmeticThis pass rewrites complex arithmetic operations into their componentscalar arithmetic operations. The pass is located in @file{tree-complex.c}and is described by @code{pass_lower_complex}.@item Scalar replacement of aggregatesThis pass rewrites suitable non-aliased local aggregate variables intoa set of scalar variables. The resulting scalar variables arerewritten into SSA form, which allows subsequent optimization passesto do a significantly better job with them. The pass is located in@file{tree-sra.c} and is described by @code{pass_sra}.@item Dead store eliminationThis pass eliminates stores to memory that are subsequently overwrittenby another store, without any intervening loads. The pass is locatedin @file{tree-ssa-dse.c} and is described by @code{pass_dse}.@item Tail recursion eliminationThis pass transforms tail recursion into a loop. It is located in@file{tree-tailcall.c} and is described by @code{pass_tail_recursion}.@item Forward store motionThis pass sinks stores and assignments down the flowgraph closer to theiruse point. The pass is located in @file{tree-ssa-sink.c} and isdescribed by @code{pass_sink_code}.@item Partial redundancy eliminationThis pass eliminates partially redundant computations, as well asperforming load motion. The pass is located in @file{tree-ssa-pre.c}and is described by @code{pass_pre}.Just before partial redundancy elimination, if@option{-funsafe-math-optimizations} is on, GCC tries to convertdivisions to multiplications by the reciprocal. The pass is locatedin @file{tree-ssa-math-opts.c} and is described by@code{pass_cse_reciprocal}.@item Full redundancy eliminationThis is a simpler form of PRE that only eliminates redundancies thatoccur an all paths. It is located in @file{tree-ssa-pre.c} anddescribed by @code{pass_fre}.@item Loop optimizationThe main driver of the pass is placed in @file{tree-ssa-loop.c}and described by @code{pass_loop}.The optimizations performed by this pass are:Loop invariant motion. This pass moves only invariants thatwould be hard to handle on rtl level (function calls, operations that expand tonontrivial sequences of insns). With @option{-funswitch-loops} it also movesoperands of conditions that are invariant out of the loop, so that we can usejust trivial invariantness analysis in loop unswitching. The pass also includesstore motion. The pass is implemented in @file{tree-ssa-loop-im.c}.Canonical induction variable creation. This pass creates a simple counterfor number of iterations of the loop and replaces the exit condition of theloop using it, in case when a complicated analysis is necessary to determinethe number of iterations. Later optimizations then may determine the numbereasily. The pass is implemented in @file{tree-ssa-loop-ivcanon.c}.Induction variable optimizations. This pass performs standard inductionvariable optimizations, including strength reduction, induction variablemerging and induction variable elimination. The pass is implemented in@file{tree-ssa-loop-ivopts.c}.Loop unswitching. This pass moves the conditional jumps that are invariantout of the loops. To achieve this, a duplicate of the loop is created foreach possible outcome of conditional jump(s). The pass is implemented in@file{tree-ssa-loop-unswitch.c}. This pass should eventually replace thertl-level loop unswitching in @file{loop-unswitch.c}, but currentlythe rtl-level pass is not completely redundant yet due to deficienciesin tree level alias analysis.The optimizations also use various utility functions contained in@file{tree-ssa-loop-manip.c}, @file{cfgloop.c}, @file{cfgloopanal.c} and@file{cfgloopmanip.c}.Vectorization. This pass transforms loops to operate on vector typesinstead of scalar types. Data parallelism across loop iterations is exploitedto group data elements from consecutive iterations into a vector and operate on them in parallel. Depending on available target support the loop is conceptually unrolled by a factor @code{VF} (vectorization factor), which isthe number of elements operated upon in parallel in each iteration, and the @code{VF} copies of each scalar operation are fused to form a vector operation.Additional loop transformations such as peeling and versioning may take placeto align the number of iterations, and to align the memory accesses in the loop.The pass is implemented in @file{tree-vectorizer.c} (the main driver and generalutilities), @file{tree-vect-analyze.c} and @file{tree-vect-transform.c}.Analysis of data references is in @file{tree-data-ref.c}.Autoparallelization. This pass splits the loop iteration space to runinto several threads. The pass is implemented in @file{tree-parloops.c}.@item Tree level if-conversion for vectorizerThis pass applies if-conversion to simple loops to help vectorizer.We identify if convertible loops, if-convert statements and mergebasic blocks in one big block. The idea is to present loop in suchform so that vectorizer can have one to one mapping between statementsand available vector operations. This patch re-introduces COND_EXPRat GIMPLE level. This pass is located in @file{tree-if-conv.c} and isdescribed by @code{pass_if_conversion}.@item Conditional constant propagationThis pass relaxes a lattice of values in order to identify thosethat must be constant even in the presence of conditional branches.The pass is located in @file{tree-ssa-ccp.c} and is describedby @code{pass_ccp}.A related pass that works on memory loads and stores, and not justregister values, is located in @file{tree-ssa-ccp.c} and described by@code{pass_store_ccp}.@item Conditional copy propagationThis is similar to constant propagation but the lattice of values isthe ``copy-of'' relation. It eliminates redundant copies from thecode. The pass is located in @file{tree-ssa-copy.c} and described by@code{pass_copy_prop}.A related pass that works on memory copies, and not just registercopies, is located in @file{tree-ssa-copy.c} and described by@code{pass_store_copy_prop}.@item Value range propagationThis transformation is similar to constant propagation butinstead of propagating single constant values, it propagatesknown value ranges. The implementation is based on Patterson'srange propagation algorithm (Accurate Static Branch Prediction byValue Range Propagation, J. R. C. Patterson, PLDI '95). Incontrast to Patterson's algorithm, this implementation does notpropagate branch probabilities nor it uses more than a singlerange per SSA name. This means that the current implementationcannot be used for branch prediction (though adapting it wouldnot be difficult). The pass is located in @file{tree-vrp.c} and isdescribed by @code{pass_vrp}.@item Folding built-in functionsThis pass simplifies built-in functions, as applicable, with constantarguments or with inferable string lengths. It is located in@file{tree-ssa-ccp.c} and is described by @code{pass_fold_builtins}.@item Split critical edgesThis pass identifies critical edges and inserts empty basic blockssuch that the edge is no longer critical. The pass is located in@file{tree-cfg.c} and is described by @code{pass_split_crit_edges}.@item Control dependence dead code eliminationThis pass is a stronger form of dead code elimination that caneliminate unnecessary control flow statements. It is locatedin @file{tree-ssa-dce.c} and is described by @code{pass_cd_dce}.@item Tail call eliminationThis pass identifies function calls that may be rewritten intojumps. No code transformation is actually applied here, but thedata and control flow problem is solved. The code transformationrequires target support, and so is delayed until RTL@. In themeantime @code{CALL_EXPR_TAILCALL} is set indicating the possibility.The pass is located in @file{tree-tailcall.c} and is described by@code{pass_tail_calls}. The RTL transformation is handled by@code{fixup_tail_calls} in @file{calls.c}.@item Warn for function return without valueFor non-void functions, this pass locates return statements that donot specify a value and issues a warning. Such a statement may havebeen injected by falling off the end of the function. This pass isrun last so that we have as much time as possible to prove that thestatement is not reachable. It is located in @file{tree-cfg.c} andis described by @code{pass_warn_function_return}.@item Mudflap statement annotationIf mudflap is enabled, we rewrite some memory accesses with code tovalidate that the memory access is correct. In particular, expressionsinvolving pointer dereferences (@code{INDIRECT_REF}, @code{ARRAY_REF},etc.) are replaced by code that checks the selected address rangeagainst the mudflap runtime's database of valid regions. This checkincludes an inline lookup into a direct-mapped cache, based onshift/mask operations of the pointer value, with a fallback functioncall into the runtime. The pass is located in @file{tree-mudflap.c} andis described by @code{pass_mudflap_2}.@item Leave static single assignment formThis pass rewrites the function such that it is in normal form. Atthe same time, we eliminate as many single-use temporaries as possible,so the intermediate language is no longer GIMPLE, but GENERIC@. Thepass is located in @file{tree-outof-ssa.c} and is described by@code{pass_del_ssa}.@item Merge PHI nodes that feed into one anotherThis is part of the CFG cleanup passes. It attempts to join PHI nodesfrom a forwarder CFG block into another block with PHI nodes. Thepass is located in @file{tree-cfgcleanup.c} and is described by@code{pass_merge_phi}.@item Return value optimizationIf a function always returns the same local variable, and that localvariable is an aggregate type, then the variable is replaced with thereturn value for the function (i.e., the function's DECL_RESULT). Thisis equivalent to the C++ named return value optimization applied toGIMPLE@. The pass is located in @file{tree-nrv.c} and is described by@code{pass_nrv}.@item Return slot optimizationIf a function returns a memory object and is called as @code{var =foo()}, this pass tries to change the call so that the address of@code{var} is sent to the caller to avoid an extra memory copy. Thispass is located in @code{tree-nrv.c} and is described by@code{pass_return_slot}.@item Optimize calls to @code{__builtin_object_size}This is a propagation pass similar to CCP that tries to remove callsto @code{__builtin_object_size} when the size of the object can becomputed at compile-time. This pass is located in@file{tree-object-size.c} and is described by@code{pass_object_sizes}.@item Loop invariant motionThis pass removes expensive loop-invariant computations out of loops.The pass is located in @file{tree-ssa-loop.c} and described by@code{pass_lim}.@item Loop nest optimizationsThis is a family of loop transformations that works on loop nests. Itincludes loop interchange, scaling, skewing and reversal and they areall geared to the optimization of data locality in array traversalsand the removal of dependencies that hamper optimizations such as loopparallelization and vectorization. The pass is located in@file{tree-loop-linear.c} and described by@code{pass_linear_transform}.@item Removal of empty loopsThis pass removes loops with no code in them. The pass is located in@file{tree-ssa-loop-ivcanon.c} and described by@code{pass_empty_loop}.@item Unrolling of small loopsThis pass completely unrolls loops with few iterations. The passis located in @file{tree-ssa-loop-ivcanon.c} and described by@code{pass_complete_unroll}.@item Predictive commoningThis pass makes the code reuse the computations from the previousiterations of the loops, especially loads and stores to memory.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -