tree-optimization: Fix reassoc for abnormal SSA uses
Reassociation pass now correctly handles abnormal SSA uses, preventing issues with out-of-SSA coalescing.
This commit enhances the tree reassociation optimization pass by adding checks to is_reassociable_op. These checks ensure that abnormal uses of Static Single Assignment (SSA) values are not rescheduled, which could otherwise break out-of-SSA coalescing. The changes include modifications to acceptable_pow_call and try_special_add_to_ops in tree-ssa-reassoc.cc and add a new test case.
In Details
The tree-ssa-reassoc pass in GCC is responsible for reordering associative operations to improve code. This patch refines the is_reassociable_op predicate by introducing checks for abnormal SSA uses, specifically within acceptable_pow_call and try_special_add_to_ops. Abnormal SSA uses occur when an SSA value is used in a way that violates SSA properties (e.g., before its definition or in a complex control flow path). By ensuring these are not rescheduled, the pass avoids breaking the out-of-SSA (OOSSA) coalescing pass, which relies on well-formed SSA properties for efficient register…
- tree-optimization
- A phase in GCC that operates on the GIMPLE intermediate representation (often referred to as 'tree' representation) to perform various optimizations.
- Reassociation
- An optimization technique that changes the grouping of associative operations (like addition or multiplication) without changing the result, potentially enabling other optimizations or improving instruction scheduling.
- SSA
- Static Single Assignment. An intermediate representation property where each variable is assigned a value exactly once. This simplifies many analyses and optimizations.
- Out-of-SSA (OOSSA) coalescing
- A compiler optimization pass that attempts to merge or 'coalesce' variables that are no longer strictly in SSA form, aiming to reduce register pressure and improve performance.