i386: Use F16C/AVX512VL for _Float16 to double conversion
Enables faster _Float16 to double conversions on x86 using F16C/AVX512VL, avoiding libgcc calls.
This commit enables the use of the F16C and AVX512VL extensions for converting _Float16 (half-precision float) to _Float64 (double-precision float) on i386 architectures. Previously, without the AVX512FP16 instruction set, GCC would emit a call to a libgcc helper function. Now, for processors supporting F16C or AVX512VL, GCC emits a sequence of vcvtph2ps (half-precision to single-precision) and vcvtss2sd (single-precision to double-precision) instructions. This provides a significant performance improvement by avoiding the overhead of a function call.
In Details
The extendhfdf2 machine description entry in i386.md handles the conversion from _Float16 to _Float64. This commit expands the condition under which this expansion is used to include TARGET_F16C || TARGET_AVX512VL. When these targets are met, the expansion is defined as a sequence: first, extendhfsf2 (using vcvtph2ps) which converts _Float16 to _Float32, and then extendsfdf2 (using vcvtss2sd) which converts _Float32 to _Float64. This sequence correctly handles sNaN inputs via the vcvtph2ps instruction and avoids the fallback to a libgcc call for targets that lack…
- _Float16
- A floating-point data type representing half-precision floating-point numbers, typically using 16 bits. It offers reduced memory usage and bandwidth compared to single-precision or double-precision, at the cost of lower precision and range.
- _Float64
- A floating-point data type representing double-precision floating-point numbers, typically using 64 bits. It offers higher precision and a wider range than single-precision or half-precision.
- F16C
- An x86 instruction set extension that provides hardware support for conversions between half-precision and single-precision floating-point formats.
- AVX512VL
- A component of the AVX-512 instruction set that extends the width of AVX-512 vector operations to 128-bit and 256-bit registers on top of 512-bit registers, allowing for more flexible vector processing.
- vcvtph2ps
- An AVX instruction that converts packed half-precision floating-point values to packed single-precision floating-point values.
- vcvtss2sd
- An AVX instruction that converts a scalar single-precision floating-point value to a scalar double-precision floating-point value.
- libgcc
- A helper library used by GCC to provide runtime support for operations that cannot be directly generated by the compiler, such as complex arithmetic, floating-point conversions, or exception handling.