Add sdot_prod expanders for BF16 and FP16 inputs
Enables AVX512BF16 and AVX10.2 instructions for BF16/FP16 dot products, allowing vectorizer to use them for floating-point operations.
This change introduces support for the sdot_prod optab with BF16 and FP16 inputs, utilizing existing AVX512BF16 vdpbf16ps and AVX10.2 vdpphps instructions. This enhancement allows the vectorizer to perform floating-point dot products on these smaller data types. The implementation requires the flag_unsafe_math_optimizations due to the behavior of vdpbf16ps with denormal inputs and result flushing. New test cases are added to cover these functionalities.
In Details
New expanders for sdot_prod have been added to the i386 backend, targeting BF16 and FP16 inputs with a floating-point accumulator. This leverages the vdpbf16ps (AVX512BF16) and vdpphps (AVX10.2) instructions. The optab expansion requires flag_unsafe_math_optimizations because vdpbf16ps treats denormal inputs as zero and flushes denormal outputs, a behavior that aligns with unsafe math optimizations. The vectorizer can now utilize these instructions for dot product operations on packed BF16 and FP16 values.
- sdot_prod
- An operation that computes a dot product of signed integer operands, often used in matrix multiplication and other linear algebra operations. In this context, it's extended to handle floating-point and specific data types.
- optab
- Operation table. A data structure in GCC used to map operations to specific machine instructions or expanders.
- BF16
- BFloat16. A 16-bit floating-point format that uses the same exponent representation as FP32 but a shorter mantissa, offering a wider dynamic range than FP16 at the cost of precision. It's common in machine learning workloads.
- FP16
- Half-precision floating-point format. A 16-bit floating-point format with reduced range and precision compared to FP32.
- AVX512BF16
- An extension to the AVX-512 instruction set that provides instructions for processing BFloat16 data types.
- AVX10.2
- A version of the AVX instruction set that includes features from AVX-512, designed for wider compatibility across Intel and AMD processors.
- vectorizer
- A compiler component that transforms code to use SIMD (Single Instruction, Multiple Data) instructions, allowing a single instruction to operate on multiple data elements simultaneously.
- denormal numbers
- Floating-point numbers that are too small to be represented in the normal normalized format. Operations on denormals can be slower and may be flushed to zero by certain instructions.