i386: Avoid emulated broadcasts of vector constants [PR127025]
Optimizes vector constant broadcasting on x86 by using dedicated instructions.
This commit refactors the expansion of vector constant broadcasts on i386 architectures to improve efficiency. It now exclusively uses dedicated broadcast instructions (AVX, or AVX2 for 16-bit elements) for floating-point constants when available. For integer constants, it respects the TARGET_PREFER_BCST_FROM_INTEGER flag, avoiding inefficient sequences like movss + shufps and ensuring optimal code generation for vector operations.
In Details
This patch revises ix86_expand_vector_move in i386-expand.cc to optimize vector constant broadcasting. It now prioritizes hardware broadcast instructions (AVX/AVX2) for FP constants and gates integer broadcasts with TARGET_PREFER_BCST_FROM_INTEGER. This change avoids emulating broadcasts with sequences like movss + shufps and ensures correct behavior for PR127897.
- AVX
- Advanced Vector Extensions, an x86 instruction set extension that increases the width of integer and floating-point vector operations to 256 bits.
- AVX2
- An extension to AVX that further enhances integer operations and adds new instructions, including for 16-bit integer operations.
- vector constant broadcasting
- A process where a single scalar value is efficiently loaded into multiple elements of a vector register. This is often optimized using specialized CPU instructions.
- PR127897
- A problem report (bug tracker ID) filed against GCC, indicating an issue with vector constant broadcasting on x86 architectures.