GCC Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
gcc/i386

i386: Fix extendhfdf2 expander with -mgeneral-regs-only

i386 floating-point conversion instruction expander corrected for general-purpose registers.

The expander for the extendhfdf2 instruction on i386 has been fixed when using the -mgeneral-regs-only option. Previously, the expander incorrectly assumed that the second step of the conversion (HF to SF, then SF to DF) was always available, even when neither x87 nor SSE math hardware was present. This commit ensures that the expander now correctly requires the necessary hardware support (x87 or SSE2/SSE_MATH) for the SF to DF conversion when AVX512FP16 is not used, preventing expansion failures.

In Details

This commit corrects the extendhfdf2 expander in i386.md for the x86 architecture. The issue arises when TARGET_AVX512FP16 is not defined, causing the expansion to rely on a two-step process: extendhfsf2 followed by extendsfdf2. The original condition only checked for F16C or AVX512VL (related to extendhfsf2), but not for extendsfdf2. When -mgeneral-regs-only is used on IA32, neither x87 nor SSE math is available, leading to a failure in the extendsfdf2 step. The fix adds the necessary conditions (TARGET_80387 or TARGET_SSE2 && TARGET_SSE_MATH) for the extendsfdf2…

For Context
extendhfdf2
An internal GCC instruction pattern for converting a half-precision floating-point value (HF) to a double-precision floating-point value (DF).
-mgeneral-regs-only
A GCC target specific flag that restricts the use of floating-point registers, forcing FP operations to use general-purpose registers with scalar instructions.
expander
A piece of compiler code that replaces a high-level or generic instruction with a sequence of more specific, lower-level instructions.
HF
Half-precision floating-point format (typically 16-bit).
DF
Double-precision floating-point format (typically 64-bit).
SSE
Streaming SIMD Extensions. A set of CPU instructions for single instruction, multiple data (SIMD) operations, including floating-point arithmetic.
Filed Under: i386optimizationfloating-pointbugfix