x86: Move CTOR gpr<->xmm move costing to add_slp_cost overload
Vectorizer's GPR-to-XMM move costing for constructors moved to a more appropriate SLP hook.
GCC’s x86 vectorizer has refactored how it costs moves between general-purpose registers (GPRs) and XMM registers during vector constructor operations. Previously, this costing was performed in a less efficient manner within the add_stmt_cost hook, potentially leading to redundant calculations. The change moves this costing logic to the add_slp_cost overload, which is invoked once per SLP node, eliminating duplicate costing and improving the accuracy of cost estimations for vectorization.
In Details
This commit addresses redundant GPR<->XMM move costing within the x86 vectorizer's SLP (Superword-Level Parallelism) cost model. Previously, the add_stmt_cost hook would iterate over SLP node scalar definitions, re-calculating move costs for vector constructor (vec_construct) patterns. By moving this logic to a dedicated ix86_vector_costs::add_slp_cost overload, which receives the SLP node directly and is called only once per node, the compiler avoids repeated costing of these inter-register moves. vect_prologue_cost_for_slp is updated to consistently provide the SLP node to all cost…
- vectorizer
- A component of a compiler that transforms code, typically loops, to use SIMD (Single Instruction, Multiple Data) instructions, allowing parallel processing of multiple data elements with a single instruction.
- GPR
- General-Purpose Register. These are the primary registers available in a CPU for general computation and data manipulation.
- XMM registers
- Registers used by SSE (Streaming SIMD Extensions) and AVX (Advanced Vector Extensions) instructions for floating-point and integer SIMD operations. They are typically 128-bit or 256-bit wide.
- SLP
- Superword-Level Parallelism. A compiler optimization technique that identifies opportunities to vectorize code by finding sequences of scalar operations on different data items that can be executed in parallel using SIMD instructions.
- add_stmt_cost
- A hook or function within the GCC cost model that estimates the computational cost of a statement or instruction.
- add_slp_cost
- A hook or function within the GCC cost model specifically designed to estimate the cost of operations related to SLP vectorization.
- vec_construct
- Represents the construction of a vector from scalar elements or other vectors within GCC's intermediate representation.