Live lane check: Fix dominance for PHI nodes
Corrects dominance checks in live lane extraction for PHI nodes, improving vectorization reliability.
This commit fixes a bug in the live lane extraction dominance check within the vectorization pass, specifically when dealing with PHI (Промежуточная Инструкция) nodes. Previously, the compiler did not correctly verify the dominance of the vector definition with the scalar use in cases involving PHI uses. The fix ensures that the respective PHI edge source can reach the definition, thereby correctly establishing dominance. This resolves PR tree-optimization/126862 and improves the accuracy of vectorization by ensuring scalar uses of PHI nodes are properly dominated by their vector definitions.
In Details
The vect_bb_slp_mark_live_stmts function in tree-vect-slp.cc performs dominance checks to ensure that a scalar use can be safely replaced by a vector load. When the scalar use involves a PHI node, the original check failed to correctly verify dominance. Specifically, it did not ensure that the source of the PHI edge (which represents a value from a preceding basic block) could reach the definition of the vector value. This commit adds a check for this condition, ensuring that the scalar use is indeed dominated by the definition, which is crucial for correctness when vectorizing code with…
- Live lane extraction
- A technique used in vectorization to determine which lanes (elements) of a vector register are actively used by subsequent scalar operations. This helps in optimizing vector register allocation and usage.
- Dominance
- In control flow graphs, node A dominates node B if every path from the entry node to node B must go through node A. Dominance is a key concept for many compiler optimizations, ensuring that certain transformations are safe.
- PHI node
- An instruction in Static Single Assignment (SSA) form that represents the merging of values from different control flow paths. A PHI node takes multiple arguments, one from each predecessor block, and selects the appropriate value based on which predecessor was taken.
- tree-optimization
- The phase in GCC where optimizations are applied to the intermediate representation, known as the GCC Tree. This pass focuses on vectorization and SLP.