Optimization Passes List
This is an automatically generated list of all optimization passes available
with the default opt_main
. This is generated automatically based on comments
in the header files.
If the opt level is set below 'Min opt level' the pass will act as a no-op.
If the opt level is set above 'Cap opt level' the pass (or passes within the compound pass) will be executed with the opt level capped to the specified value.
default_pipeline - The default pipeline.
Invoked Passes
arith_simp - Arithmetic Simplifications
This pass performs various arithmetic optimizations such as replacement of divide by a constant with non-divide operations.
array_simp - Array Simplification
Pass which simplifies or eliminates some array-type operations such as ArrayIndex.
array_untuple - Array UnTuple
Pass which changes any (non-external) array-of-tuple into a tuple-of-arrays. We can see through tuples quite well but can't see through arrays to anywhere near the same extent. Therefore the struct-of-array representation is always superior.
Note that this pass makes no attempt to unpack or repack arrays which escape the function-base. This means that anything which comes in through a function param, or a procs recv or escapes through a function return or a proc send is not untuple'd. TODO(allight): We could do this at the cost of a significant number of ir nodes. We should experiment to see if this is worth doing.
basic_simp - Basic Simplifications
This pass does simple pattern-matching optimizations which are ~always a good idea to do (replacing a node with a constant, removing operands of nodes, etc). They improve QoR, do not increase the number of nodes in the graph, preserve the same abstraction level, and do not impede later optimizations via obfuscation. These optimizations require no analyses beyond looking at the node and its operands. Examples include: not(not(x)) => x, x + 0 => x, etc.
bdd_cse - BDD-based Common Subexpression Elimination
Pass which commons equivalent expressions in the graph using binary decision diagrams.
bdd_simp - BDD-based Simplification
Runs BDD-based simplifications on the function. Currently this is a very limited set of optimization including one-hot removal and replacement of statically known values with literals. TODO(meheff): Add more BDD-based optimizations.
bdd_simp(2) - BDD-based Simplification with opt_level <= 2
Runs BDD-based simplifications on the function. Currently this is a very limited set of optimization including one-hot removal and replacement of statically known values with literals. TODO(meheff): Add more BDD-based optimizations.
bdd_simp(3) - BDD-based Simplification with opt_level <= 3
Runs BDD-based simplifications on the function. Currently this is a very limited set of optimization including one-hot removal and replacement of statically known values with literals. TODO(meheff): Add more BDD-based optimizations.
bitslice_simp - Bit-slice simplification
Pass which simplifies bit-slices. This includes collapsing sequential bit-slices, eliminating degenerate full-width slices, and others.
bool_simp - boolean simplification
Attempts to simplify bitwise / boolean expressions (e.g. of multiple variables).
canon - Canonicalization
class CanonicalizationPass iterates over nodes and tries to canonicalize the expressions found. For example, for an add between a node and a literal, the literal should only be the 2nd operand. This preprocessing of the IR helps to simplify later passes.
channel_legalization - Legalize multiple send/recvs per channel
Pass that legalizes multiple send/receive operations per channel.
This pass adds cross-activation tokens to guarantee that later activations of a proc cannot send or receive on a channel until all previous activations have completed working with that channel.
comparison_simp - Comparison Simplification
Simplifies logical operations on the results of comparison operations. For example:
eq(x, 0) && ne(x, 1) => eq(x, 0) eq(x, 0) && ne(x, 0) => 0 eq(x, 0) || ne(x, 0) => 1
concat_simp - Concat simplification
Pass which simplifies concats. This includes removing single-operand concats, flattening trees of dependent concats, and others.
cond_spec(Bdd) - Conditional specialization
Pass which specializes arms of select operations based on their selector value.
cond_spec(false) - Conditional specialization
Pass which specializes arms of select operations based on their selector value.
cond_spec(noBdd) - Conditional specialization
Pass which specializes arms of select operations based on their selector value.
cond_spec(true) - Conditional specialization
Pass which specializes arms of select operations based on their selector value.
const_fold - Constant folding
Pass which performs constant folding. Every op with only literal operands is replaced by a equivalent literal. Runs DCE after constant folding.
cse - Common subexpression elimination
Pass which performs common subexpression elimination. Equivalent ops with the same operands are commoned. The pass can find arbitrarily large common expressions.
dataflow - Dataflow Optimization
An optimization which uses a lattice-based dataflow analysis to find equivalent nodes in the graph and replace them with a simpler form. The analysis traces through tuples, arrays, and select operations. Optimizations which can be performed by this pass:
tuple_index(tuple(x, y), index=1) => y
select(selector, {z, z}) => z
array_index(array_update(A, x, index={42}), index={42}) => x
dce - Dead Code Elimination
class DeadCodeEliminationPass iterates up from a functions result nodes and marks all visited node. After that, all unvisited nodes are considered dead.
dfe - Dead Function Elimination
This pass removes unreachable procs/blocks/functions from the package. The pass requires top
be set in order remove any constructs.
fixedpoint_proc_state_flattening - Proc State Flattening
Prepare proc state for further analysis by removing arrays and tuples.
Options Set
Run to a fixedpoint.
Invoked Passes
fixedpoint_simp - Fixed-point Simplification
Standard simplification pipeline.
This is run to a fixedpoint and avoids many time-consuming analyses.
Options Set
Run to a fixedpoint.
Invoked Passes
fixedpoint_simp(2) - Max-2 Fixed-point Simplification
Standard simplification pipeline.
Opt level is capped at 2
Options Set
Run to a fixedpoint.
Cap opt level: 2
Invoked Passes
fixedpoint_simp(3) - Max-3 Fixed-point Simplification
Standard simplification pipeline.
Opt level is capped at 3
Options Set
Run to a fixedpoint.
Cap opt level: 3
Invoked Passes
fixedpoint_simp(>=1,<=2) - Min-1 Max-2 Fixedpoint Simplification
Standard simplification pipeline.
Opt level is capped at 2 and skipped if less than 1
Options Set
Run to a fixedpoint.
Min opt level: 1
Cap opt level: 2
Invoked Passes
full-inlining - full function inlining passes
Fully inline all functions in a single step.
Invoked Passes
ident_remove - Identity Removal
class IdentityRemovalPass eliminates all identity() expressions by forward substituting it's parameters to the uses of the identity's def.
inlining - Inlines invocations
Inlines a package toward the top
function/proc.
If full
then all functions are inlined into the top
.
If leaf
then only leaf functions are inlined into their caller. This allows other passes to optimize on smaller graphs.
label-recovery - LabelRecovery
At the end of the pass pipeline (when inlining and optimizations have been performed) attempts to recover original names for coverpoints and assertions to whatever degree possible so they're more human-readable -- we mangle them for inlining to ensure they're unique, but often those names are way overqualified.
leaf-inlining - Inlines invocations
Inlines a package toward the top
function/proc.
If full
then all functions are inlined into the top
.
If leaf
then only leaf functions are inlined into their caller. This allows other passes to optimize on smaller graphs.
loop_unroll - Unroll counted loops
lut_conversion - LUT Conversion
Pass which opportunistically converts nodes to lookup tables (selects) where we can prove it's beneficial.
map_inlining - Inline map operations
A pass to convert map nodes to in-line Invoke nodes. We don't directly lower maps to Verilog.
narrow - Narrowing
A pass which reduces the width of operations eliminating redundant or unused bits.
narrow(Context) - Narrowing
A pass which reduces the width of operations eliminating redundant or unused bits.
narrow(OptionalContext) - Narrowing
A pass which reduces the width of operations eliminating redundant or unused bits.
narrow(Range) - Narrowing
A pass which reduces the width of operations eliminating redundant or unused bits.
narrow(Ternary) - Narrowing
A pass which reduces the width of operations eliminating redundant or unused bits.
next_value_opt - Next Value Optimization
Pass which tries to optimize next_value
nodes.
Optimizations include: - removing literal predicates on next_value
nodes (removing the next_value
node if dead), - splitting next_value
nodes with select
-based values (if small), - splitting next_value
nodes with priority_sel
-based values, and - splitting next_value
nodes with one_hot_sel
-based values (where safe).
For best results, first modernizes old-style values on next (...)
lines, converting them to next_value
nodes.
next_value_opt(3) - max-3 next value optimization
Next value opt capped at 3
Options Set
Cap opt level: 3
Invoked Passes
non_synth_separation - Non-Synthesizable Separation
Separates out non-synthesizable nodes like assert/cover/trace from the main function into a cloned function. Every function effectively has two versions, one with synthesizable nodes and one without. The synthesizable version invokes the non-synthesizable version of its function. This ensures that non-synthesizable uses of values do not affect the optimization of the synthesizable parts of the function.
one-leaf-inlining - leaf function inlining passes
inline one level of functions.
Invoked Passes
post-inlining - Post-inlining passes
Passes performed after inlining
Invoked Passes
post-inlining-opt - post-inlining optimization passes
Passes performed after inlining
Invoked Passes
- fixedpoint_simp(2)
- cond_spec(noBdd)
- dce
- bdd_simp(2)
- dce
- bdd_cse
- dce
- cond_spec(Bdd)
- dce
- fixedpoint_simp(2)
- narrow(OptionalContext)
- dce
- basic_simp
- dce
- arith_simp
- dce
- cse
- sparsify_select
- dce
- useless_assert_remove
- ram_rewrite
- useless_io_remove
- dce
- cond_spec(Bdd)
- channel_legalization
- token_dependency
- fixedpoint_simp(2)
- fixedpoint_proc_state_flattening
- proc_state_bits_shatter
- proc_state_tuple_flat
- ident_remove
- dataflow
- next_value_opt(3)
- dce
- proc_state_narrow
- dce
- proc_state_opt
- dce
- proc_state_provenance_narrow
- dce
- proc_state_opt
- dce
- bdd_simp(3)
- dce
- bdd_cse
- select_lifting
- dce
- lut_conversion
- dce
- cond_spec(Bdd)
- dce
- fixedpoint_simp(3)
- select_range_simp
- dce
- fixedpoint_simp(3)
- bdd_simp(3)
- dce
- bdd_cse
- dce
- proc_state_bits_shatter
- proc_state_tuple_flat
- fixedpoint_simp(3)
- useless_assert_remove
- useless_io_remove
- next_value_opt(3)
- proc_state_opt
- dce
- cond_spec(Bdd)
- dce
- select_merge
- dce
- fixedpoint_simp(3)
post-inlining-opt(>=1) - min-1 post-inlining optimization passes
Passes performed after inlining
Options Set
Min opt level: 1
Invoked Passes
pre-inlining - pre-inlining passes
Passes performed before each inlining.
Invoked Passes
proc_state_array_flat - Proc State Array Flattening
Pass which flattens array elements of the proc state into their constituent elements. Tuples are flattened in a different pass. Flattening improves optimizability because each state element can be considered and transformed in isolation. Flattening also gives the scheduler more flexibility; without flattening, each element in the aggregate must have the same lifetime.
proc_state_bits_shatter - Proc State Bits Shattering
Pass which transforms Bits-type elements of the proc state into tuples of components. Only flattens where it can show that doing so will enable dynamic state feedback opportunities later (assuming it's followed by a ProcStateTupleFlatteningPass).
proc_state_narrow - Proc State Narrowing
Pass which tries to minimize the size and total number of elements of the proc state. The optimizations include removal of dead state elements and zero-width elements.
proc_state_opt - Proc State Optimization
Pass which tries to minimize the size and total number of elements of the proc state. The optimizations include removal of dead state elements and zero-width elements.
proc_state_provenance_narrow - Proc State Provenance Narrowing
Pass which tries to minimize the size and total number of elements of the proc state. This pass works by examining the provenance of the bits making up the next value to determine which (if any) bits are never actually modified.
NB This is a separate pass from ProcStateNarrowing for simplicity of implementation. That pass mostly assumes we'll have a range-analysis which this does not need.
proc_state_tuple_flat - Proc State Tuple Flattening
Pass which flattens tuple elements of the proc state into their constituent components. Array elements are flattened in a different pass. Flattening improves optimizability because each state element can be considered and transformed in isolation. Flattening also gives the scheduler more flexibility; without flattening, each element in the aggregate must have the same lifetime.
ram_rewrite - RAM Rewrite
Pass that rewrites RAMs of one type to a new type. Generally this will be some kind of lowering from more abstract to concrete RAMs.
reassociation - Reassociation
Reassociates associative operations to reduce delay by transforming chains of operations to a balanced tree of operations, and gathering together constants in the expression for folding.
recv_default - Receive default value simplification
Optimization which removes useless selects between the data value of a conditional or non-blocking receive and the default value of the receive (all zeros).
resource_sharing - Resource Sharing
select_lifting - Select Lifting
Pass which replace the pattern v = sel (c, array[i], array[j], ...) where all cases of the select reference the same array, to the code z = sel (c, i, j, ...) v = array[z]
select_merge - Select Merging
select_range_simp - Select Range Simplification
Pass which simplifies selects and one-hot-selects. Example optimizations include removing dead arms and eliminating selects with constant selectors. Uses range analysis to determine possible values.
select_simp - Select Simplification
Pass which simplifies selects and one-hot-selects. Example optimizations include removing dead arms and eliminating selects with constant selectors. Uses ternary analysis to determine possible values.
simp - Simplification
Standard simplification pipeline.
This is run a large number of times and avoids many time-consuming analyses.
Invoked Passes
- ident_remove
- const_fold
- dce
- canon
- dce
- basic_simp
- dce
- arith_simp
- dce
- comparison_simp
- dce
- table_switch
- dce
- recv_default
- dce
- select_simp
- dce
- dataflow
- dce
- reassociation
- dce
- const_fold
- dce
- narrow(Ternary)
- dce
- bitslice_simp
- dce
- concat_simp
- dce
- array_untuple
- dce
- dataflow
- dce
- strength_red
- dce
- array_simp
- dce
- cse
- dce
- basic_simp
- dce
- arith_simp
- dce
- narrow(Ternary)
- dce
- bool_simp
- dce
- token_simp
- dce
simp(2) - Max-2 Simplification
Standard simplification pipeline.
Opt level is capped at 2
Options Set
Cap opt level: 2
Invoked Passes
simp(3) - Max-3 Simplification
Standard simplification pipeline.
Opt level is capped at 3
Options Set
Cap opt level: 3
Invoked Passes
simp(>=1,<=2) - Min-1 Max-2 Simplification
Standard simplification pipeline.
Opt level is capped at 2 and skipped if less than 1
Options Set
Min opt level: 1
Cap opt level: 2
Invoked Passes
simplify-and-inline - Iteratively inline and simplify
Inlining segment of the pipeline
This is performed to fixedpoint and each run a single layer of the function hierarchy is inlined away.
Options Set
Run to a fixedpoint.
Invoked Passes
sparsify_select - Sparsify Select
The SparsifySelectPass is a type of range analysis-informed dead code elimination that removes cases from selects when range analysis proves that they can never occur. It does this by splitting a select into many selects, each of which covers a single interval from the selector interval set.
strength_red - Strength Reduction
Replaces operations with equivalent cheaper operations. For example, multiply by a power-of-two constant may be replaced with a shift left.
table_switch - Table switch conversion
TableSwitchPass converts chains of Select nodes into ArrayIndex ops. These chains have the form: sel.(N)(eq.X, literal.A, literal.B) sel.(N+1)(eq.Y, sel.(N), literal.C) sel.(N+2)(eq.Z, sel.(N+1), literal.D) And so on. In these chains, eq.X, eq.Y, and eq.Z must all be comparisons of the same value against different literals.
Current limitations: - Either the start or end index in the chain must be 0. - The increment between indices must be positive or negative 1. - There can be no "gaps" between indices. - The Select ops have to be binary (i.e., selecting between only two cases).
token_dependency - Convert data dependencies between effectful operations into token dependencies
Pass which turns data dependencies between certain effectful operations into token dependencies. In particular, transitive data dependencies between receives and other effectful ops are turned into token dependencies whenever no such token dependency already exists.
token_simp - Simplify token networks
Pass that simplifies token networks. For example, if an AfterAll node has operands where one operand is an ancestor of another in the token graph, then the ancestor can be omitted. Similarly, duplicate operands can be removed and AfterAlls with one operand can be replaced with their operand.
useless_assert_remove - Remove useless (always true) asserts
Pass which removes asserts that have a literal 1 as the condition, meaning they are never triggered. Rewires tokens to ensure nothing breaks.
useless_io_remove - Remove useless send/receive
Pass which removes sends/receives that have literal false as their condition. Also removes the condition from sends/receives that have literal true as their condition.