GCC Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
gcc/vect

Improve vectorization of complex number operations

Refine vectorization of complex number operations by correctly matching real and imaginary parts to their defining statements.

This commit addresses an issue in the vectorizer where the compatible_complex_nodes_p check was too permissive, incorrectly assuming that real and imaginary parts of complex numbers always originated from the same defining statement. The change explicitly checks the defining statements for both real and imaginary parts, ensuring more accurate vectorization of complex arithmetic. A new test case for AArch64 is included to verify the fix.

In Details

The compatible_complex_nodes_p function in tree-vect-slp-patterns.cc is used to determine if two complex number nodes are compatible for vectorization. Previously, it relied on an indirect check that did not guarantee both the REALPART and IMAGPART operations in a TWO_OPERANDS structure derived from the same source statement. This commit adds explicit checks to ensure that the defining statements for the real and imaginary components match, preventing incorrect vectorization of complex operations.

For Context
Vectorization
The process by which a compiler automatically transforms a scalar loop into a vector loop that performs the same operations on multiple data elements simultaneously using wide, single-instruction, multiple-data (SIMD) registers.
REALPART/IMAGPART
Functions or operations that extract the real and imaginary components, respectively, from a complex number.
Defining Statement
In the context of compiler intermediate representation (IR), the defining statement refers to the specific instruction or operation that generates a particular value or variable.
TWO_OPERANDS
A GIMPLE construct representing an operation with two operands, such as an addition or multiplication.
Filed Under: gcc/vectvectorizationcomplex numbersaarch64