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

Fix incorrect handling of complex number parts in addressability checks

Fixes bug where complex number components were not checked, leading to incorrect memory access analysis.

The may_be_nonaddressable_p function in tree-ssa-loop-ivopts.cc has been updated to correctly recurse for REALPART_EXPR and IMAGPART_EXPR. This resolves an issue where complex number components were not handled, causing incorrect rewrites of reverse-storage-order accesses by the IVOPTS pass.

In Details

The may_be_nonaddressable_p function, used within the loop invariant code motion (IVOPTS) pass, determines if an expression can be safely used as a memory address. Previously, it failed to recurse into REALPART_EXPR and IMAGPART_EXPR nodes, which represent the real and imaginary parts of complex numbers. This commit adds recursion for these types, ensuring that the addressability of complex number components is correctly analyzed, preventing misoptimizations.

For Context
IVOPTS
Loop Invariant Code Motion and Optimization. A compiler pass that identifies computations within loops that do not change with each iteration and moves them outside the loop to improve performance.
reverse-storage-order accesses
Memory accesses where data is read or written in the opposite order of how it is stored in memory. This can occur in certain loop transformations or when dealing with complex data structures.
REALPART_EXPR / IMAGPART_EXPR
Internal compiler representations for the real and imaginary parts of complex numbers, respectively. These are nodes in GCC's abstract syntax tree (or Gimple/Tree SSA) used during optimization.
Filed Under: optimizationtree-ssabugfix