phiopt: Limited conditional store elimination for non-diamond cases
Phiopt pass now uses a limited conditional store elimination, improving optimization for non-diamond control flow structures.
The phiopt pass has been enhanced to invoke a limited conditional store elimination function, even when code does not form a perfect diamond. This allows for earlier optimization of conditional code, particularly benefiting scenarios like the perlbmk benchmark. The limited version’s independence from store sinking expands its applicability in loop optimizations.
In Details
This commit modifies tree-ssa-phiopt.cc to call cond_store_replacement_limited from within factor_out_all. This function performs conditional store elimination, but with a restriction that makes it safe to invoke even without the full non-trapping code analysis or store sinking usually required. This enables earlier optimization of conditional assignments that don't form simple diamond control-flow graphs, potentially improving performance in loops and complex conditional logic.
- phiopt
- A GCC optimization pass that optimizes PHI nodes, which are used to represent values that result from different control flow paths merging. This pass aims to simplify and eliminate redundant computations around PHI nodes.
- conditional store elimination
- An optimization that removes redundant conditional stores. If a store within a conditional block is guaranteed to overwrite a previous store or if the conditional logic can be simplified, the redundant store can be eliminated.
- non-diamond case
- Refers to control flow graphs where the paths entering and exiting a basic block do not form a simple 'diamond' shape (i.e., a single entry and a single exit with conditional branches). This implies more complex branching structures.
- store sinking
- An optimization pass that attempts to move stores as late as possible in the program, often out of loops, to minimize their execution count.
- perlbmk
- A benchmark suite, often used to stress-test compiler performance, particularly for CPU-intensive applications that involve complex conditional logic and loops.