-
Notifications
You must be signed in to change notification settings - Fork 4
Middle end
wichtounet edited this page Nov 23, 2012
·
2 revisions
The middle end is mainly responsible for optimizations of the MTAC code.
The middle end operations are performed in the src/Compiler.cpp file.
The MTAC optimizations are managed by the Optimization Engine.
The optimization passes are applied in this order:
- All the unused functions are removed
- All the global optimizations are applied to each function
- All the empty functions are removed and the calls to them are removed from the caller
- The inliner inline all the functions that are good candidates
If one of these steps succeeds, all the steps are run again. This process is repeated until no optimization are possible.
The global optimizations are applied in this order:
- Arithmetic Identities are simplified (a = b - b => a = 0)
- Arithmetic operations are strength reduced (a = 2*a => a = a + a)
- Arithmetic operations are constant folded (a = 2 * 10 => a = 20)
- Variables with constant values are propagated (Constant Propagation)
- Aggregates with constant values are propagated
- Common Subexpression Elimination
- Basic pointer propagation pass
- Math Propagation
- Branches are optimized when the result of the comparison is known (if true goto B => goto B)
- Concatenations are simplified
- Dead basic blocks are removed
- Dead Code Elimination
- Aliases are removed (removed variables just used to hold a copy)
- Loop Analysis is performed: Loops are discovered
- Loop Invariant Code Motion
- Loop Induction Variables Optimzation
- Empty loops are removed
- Complete Loop Peeling
- Unused variables are removed