Improve BB SLP discovery for split graphs
Block SLP discovery is delayed to improve split-point identification and optimize vectorization of complex code.
This commit enhances the Basic Block (BB) Superword Level Parallelism (SLP) discovery mechanism to improve the identification of optimal split-points for code that will be further processed. By delaying the ‘soft-fail’ condition of SLP discovery until it’s absolutely necessary, the compiler can find better groupings of instructions for vectorization, particularly in cases that were previously problematic. This change avoids unnecessary overhead from operand swapping and ensures that SLP is only attempted when truly beneficial.
In Details
The vect_build_slp_tree_2 function in tree-vect-slp.cc previously had a premature soft-fail mechanism for SLP discovery. This commit delays that soft-fail until leaf nodes are reached, allowing for better discovery of vectorizable instruction sequences, especially in graphs that are intended to be split. It also avoids operand swapping on nodes that are likely to soft-fail and prevents building SLP trees from scalars if a soft-fail is imminent. This change aims to improve the effectiveness of SLP for complex control flow and data dependency scenarios, addressing issues like those in PR128…
- BB SLP
- Basic Block Superword Level Parallelism. An optimization technique that identifies and vectorizes sequences of identical instructions within a basic block.
- Basic Block (BB)
- A sequence of consecutive three-address statements which has only one entry point and one exit point.
- Superword Level Parallelism (SLP)
- A compiler optimization technique that finds redundant instructions operating on independent data elements (shuffles) and replaces them with vector instructions.
- split-points
- Points in the code where a larger instruction sequence or basic block might be divided for further processing or optimization.
- soft-fail
- A condition where an optimization attempt is not immediately abandoned but is deferred or has less impact, allowing for further analysis or alternative strategies.