Optimize splat of V2DF/V2DI extract
GCC now optimizes the 'splat' operation on extracted elements from V2DF and V2DI vectors for PowerPC.
GCC has added an optimization for PowerPC (specifically VSX instructions) that improves the ‘splat’ operation when applied to an extracted element from a V2DI (two double-precision integers) or V2DF (two double-precision floats) vector. Previously, similar optimizations existed for other vector types but were missing for these double-word vector types. The new combiner instruction significantly reduces the generated code for such operations, as demonstrated by a comparison on Power9.
In Details
A new VSX combiner instruction, vsx_splat_extract_<mode>, has been added to config/rs6000/vsx.md to optimize the scenario where an element is extracted from a V2DI or V2DF vector and then splatted to fill a vector. This optimization was present for V4SI/V4SF but missed for the double-word vector types. The new instruction provides a more efficient sequence, replacing multiple instructions with a single xxpermdi on Power9, as shown in the example for splat_dup_l_0.
- splat
- An operation that takes a single scalar value and replicates it to fill all elements of a vector register.
- V2DF
- A vector data type consisting of two elements, each being a double-precision floating-point number (64 bits).
- V2DI
- A vector data type consisting of two elements, each being a double-precision integer (64 bits).
- VSX
- Vector-Scalar Extension, a set of instructions for IBM's PowerPC and PowerPC64 architectures that allows SIMD operations on vector registers.
- combiner insn
- An instruction pattern recognized by the compiler's instruction selector that combines multiple simpler operations into a single, more efficient machine instruction.
- Power9
- A generation of IBM's POWER architecture processors, known for high performance in servers and workstations.