GCC Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
tree-optimization

tree-optimization: Avoid CSE of negated complex division/multiplication

Prevents incorrect Common Subexpression Elimination for negated complex floating-point operations.

This commit corrects an issue where the compiler incorrectly performed Common Subexpression Elimination (CSE) on negated complex floating-point divisions and multiplications. The optimization a/b -> -((-a)/b) is invalid for complex floating-point types, especially when signed zeros are involved. The compiler now avoids this specific CSE transformation for complex floats, ensuring correctness.

In Details

The visit_nary_op function in tree-ssa-sccvn.cc previously performed a Common Subexpression Elimination (CSE) that transformed expressions like a/b into -((-a)/b). This optimization is invalid for complex floating-point types due to potential issues with signed zeros and the behavior of negation with complex numbers. This change modifies the CSE logic to prevent this transformation for complex float types, addressing PR128628.

For Context
Common Subexpression Elimination (CSE)
A compiler optimization that identifies and eliminates redundant computations of the same expression, replacing subsequent occurrences with the result of the first computation.
complex floating-point
A data type representing complex numbers where both the real and imaginary parts are floating-point numbers.
signed zero
A floating-point zero value that carries information about its sign (positive or negative), which can affect comparison and arithmetic operations in certain contexts.
tree-ssa-sccvn.cc
A source file within GCC's tree- SSA (Static Single Assignment) optimization infrastructure, specifically dealing with value numbering and CSE.
Filed Under: tree-optimizationCSEcomplex numbersfloating-pointGCC