tree-ssa-dom: Avoid repeated walks in back_propagate_equivalences.
Dominator optimization pass avoids redundant equivalence checks, significantly speeding up compilation for certain code patterns.
The dominator optimization pass (tree-ssa-dom) has been optimized to prevent redundant walks in back_propagate_equivalences. Previously, the pass repeatedly traversed uses of SSA names, leading to performance issues in code with many equivalences. This change caches information about names that do not yield useful equivalences, drastically reducing compilation time and instruction count for affected programs.
In Details
The dominator optimization pass has been optimized to avoid repeated, unfruitful walks in back_propagate_equivalences. When an equivalence NAME = VALUE is recorded on an edge, the pass iterates over uses of NAME. If no dominating statement folds NAME to a constant or another name with the new value, these walks are unproductive. This change introduces names_without_foldable_uses to record such NAMEs, skipping future walks. PHI nodes are also skipped as they are never folded by gimple_fold_stmt_to_constant_1. This optimization yields substantial performance gains on test cases wi…
- Dominator Optimization
- A compiler optimization pass that analyzes the control flow graph of a program to determine dominance relationships between basic blocks. This information is used for various optimizations, including dead code elimination and constant propagation.
- SSA
- Static Single Assignment form. A representation of intermediate code where every variable is assigned a value exactly once. This simplifies many compiler analyses and optimizations.
- Equivalence
- In this context, it refers to a relationship where one SSA name can be substituted by another, often because they have been determined to hold the same value at a certain point in the program.
- Basic Block
- A sequence of instructions with a single entry point and a single exit point. Control flow enters at the beginning and proceeds without halt or possibility of diversion until the end.
- PHI node
- In SSA form, a PHI node is an instruction that merges values from different control flow paths. It indicates which version of a variable to use based on which predecessor block was executed.