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

tree-optimization/127858 - fix memory access canonicalization in LIM

tree-optimization: Fixes memory access canonicalization in the Loop Intermediate Representation (LIM).

This commit resolves an issue in memory access canonicalization within the Loop Intermediate Representation (LIM). When merging memory accesses with differing access paths, the code incorrectly failed to clear the base and offset of the access path. The fix ensures that these are properly reset to their canonical form, preventing incorrect analysis and potential optimizations.

In Details

This commit corrects a bug in tree-ssa-loop-im.cc within the gather_mem_refs_stmt function. When canonicalizing memory accesses (merging them into a MEM_REF), if the original accesses had different access paths (base + offset), the existing ao_refs base and offset were not cleared. This change ensures they are reset to the canonical form by re-using the canonical ao_ref, fixing incorrect merging of memory accesses.

For Context
memory access canonicalization
The process of transforming various forms of memory accesses (e.g., with different base pointers or offsets) into a standard, simplified representation for easier analysis and optimization.
LIM
Loop Intermediate Representation. A compiler internal representation specifically designed to facilitate analysis and transformation of loops.
MEM_REF
A tree-based representation in GCC for a memory reference, typically consisting of a base address and an offset.
SSA
Static Single Assignment form. An intermediate representation where every variable is assigned a value exactly once, simplifying many compiler analyses and optimizations.
Filed Under: optimizationcompilerloopsmemory