Transformation Passes#
Transformation passes within Pylir may either be “generic”, as in, not depending
on any upstream dialects, or specific to a dialect.
This is also reflected in the directory structure, with generic passes living in
the top level Transforms
directory of the optimizer, while the specific passes
are found in the Transforms
directory of the dialects’ directory.
Generic Transformation Passes#
-pylir-conditionals-implications
#
Simplify boolean expressions based on conditional branch paths
Statistics#
Number of simplifications made : Amount of simplification patterns that could be applied through the implications
-pylir-dce
#
Remove blocks without predecessors
Statistics#
Number of blocks removed : Number of blocks that were removed as they no longer had any predecessors
-pylir-fixpoint
#
Run optimization pipeline until fixpoint
Options#
-optimization-pipeline : Optimization pipeline to run until fixpoint
-max-iteration-count : Maximum amount of iterations if no fixpoint is reached
Statistics#
Max iterations reached : Amount of times the maximum iteration count was reached before a fixpoint
-pylir-load-forwarding
#
Forward results of stores to loads
Statistics#
Load instructions replaced : Amount of load instructions replaced
-pylir-sroa
#
Scalar Replacement Of Aggregates
Statistics#
Aggregates removed : Amount of aggregates that were removed
Aggregate read/write ops removed : Amount of read/write ops of aggregates that were removed
‘py’ Transformation Passes#
-pylir-expand-py-dialect
#
Expands ops of the Py dialect to operations that can be lowered
-pylir-fold-globals
#
Fold py.global
Statistics#
No-load Globals removed : Amount of handles that were removed as they were never loaded
Single-store Globals converted : Amount of globals converted to values as they only had a single constant store
Single-region Globals converted : Amount of globals turned to SSA as they only occur in a single region
-pylir-global-load-store-elimination
#
Eliminate loads and stores of globals
Statistics#
global loads removed : Amount of loads of globals that could be removed
Stores to globals removed : Amount of stores to globals removed
-pylir-global-sroa
#
Statistics#
Globals split : Global aggregates that have been split into their values
-pylir-inliner
#
Inline functions
Options#
-max-inlining-iterations : Maximum amount of times the inliner should attempt to inline inbetween optimizations
-threshold : Cost threshold in abstract units allowing a call-site to still be inlined. Call-sites more expensive than the threshold are not inlined
-optimization-pipeline : Optimization pipeline interleaved between inlining
-cycle-penalty : Penalty in abstract units, applied to the cost of a call-site for each occurrence of a repeated inlining of a callable, through that call-site
Statistics#
Calls inlined : Amount of call sites inlined
Optimization pipeline run : Amount of times the optimization pipeline was run
Direct recursions discarded : Amount of callsites not considered while inlining as they call themselves
Callsites considered too expensive to inline : Amount of callsites whose inlining cost is greater than the threshold
No more inlining changes to be done : 1 if the pass stopped due to not wanting to inline any more callsites instead of having reached the inlining iteration limit.
‘pyMem’ Transformation Passes#
-pylir-heap-to-stack
#
Options#
-max-object-size : Max amount of pointer sizes an object may have to still be allocated on the stack. Currently only counts trailing items.
Statistics#
Heap allocations replaced : Amount of heap allocations replaced with stack allocations
‘pyHIR’ Transformation Passes#
-pylir-class-body-outlining
#
Converts all pyHIR.class
ops to by outlining the bodies to pyHIR.func
ops and replacing them with pyHIR.buildClass
ops.
-pylir-func-outlining
#
Outlines all pyHIR.func
ops and transforms them to pyHIR.globalFunc
ops and function object creation ops.