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

vect: Restrict complex multiplication commutative validation

Temporarily restricts vectorization of complex multiplications to avoid incorrect code generation due to operand swapping issues.

This commit temporarily restricts the vect_validate_multiplication_commutative function to only four forms. This is a precautionary measure because flipping the operands of a complex multiplication can change the sign of the result, requiring an adjustment operation that the current GCC trunk cannot yet handle. By limiting the scope, the patch prevents incorrect code generation that arose from backporting changes from a complex numbers branch.

In Details

The vect_validate_multiplication_commutative function in tree-vect-slp-patterns.cc has been restricted to four specific operand swap forms. This is a workaround for PR126589, where the ability to swap operands in complex multiplication, while mathematically valid, can lead to sign changes that require compensatory adjustments. Since the current vectorizer infrastructure in the main branch does not fully support these adjustments when operand order is changed, the restricted set prevents incorrect code generation.

For Context
Vectorization
The process of transforming scalar code into vector code, where a single instruction operates on multiple data elements simultaneously. This is a key optimization technique for improving performance on modern processors with SIMD capabilities.
Commutative
An operation is commutative if the order of its operands does not affect the result (e.g., a + b = b + a). Multiplication of complex numbers is generally commutative.
Complex numbers
Numbers that can be expressed in the form a + bi, where 'a' is the real part, 'b' is the imaginary part, and 'i' is the imaginary unit (the square root of -1). They are used in various scientific and engineering fields.
PR126589
A GCC problem report identifier. These reports track bugs or feature requests within the GCC project.
Filed Under: vectoptimizationcomplex numbers