GCC Newspaper
JULY 29, 2026
Date
/
Architectures
Components
Topics
News & Policy
gcc Performance Win

PR target/99668: Improved complex to vector RTL expansion.

Optimizes casting complex numbers to two-component vectors by avoiding memory spills.

This commit enhances the RTL expansion for casting complex numbers to two-component vectors with the same inner type, addressing PR99668. Previously, this conversion involved spilling the complex number to memory. The improved process now uses the backend’s vec_init_optab to directly construct the vector from the real and imaginary parts, yielding significantly more efficient code.

In Details

The RTL expansion of VIEW_CONVERT_EXPR from complex types to two-element vectors sharing the same base type is now optimized using vec_init_optab in gcc/expr.cc. Previously, this conversion required an intermediate spill to memory. The change aims to directly generate code equivalent to (v2x){__real__ z,__imag__ z}, particularly benefiting cases like casting _Complex double to v2df (a vector of two doubles). This optimization is demonstrated with generated assembly for both the old and new code paths.

For Context
RTL expansion
The process in GCC where intermediate representations (like GENERIC or GIMPLE) are converted into Register Transfer Language (RTL), a lower-level representation closer to machine code. This is where many target-independent optimizations occur.
complex number
A data type representing a number with a real and an imaginary part, often denoted as a + bi.
vector type
A data type that holds multiple elements of the same underlying type, which can be processed in parallel by SIMD instructions.
vec_init_optab
An internal GCC table (optimization table) that provides a standardized way for backends to initialize vector types, often used in conjunction with compiler intrinsics or specific vector operations.
PR99668
A Problem Report (PR) identifier in the GCC bug tracking system, indicating a specific issue that has been reported and is being addressed.
Filed Under: optimizationvectorizationcomplex numbersbugfixSSE