GCC Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
gcc/ssa Performance Win

Improve lexical comparison of SSA VN references for restrict qualifiers

Fixed SSA prepass to correctly distinguish restricted and non-restricted references by comparing base and clique.

This commit enhances the Static Single Assignment (SSA) prepass by refining the lexical comparison of Value Number (VN) references. Previously, the comparison missed crucial details about the base and clique of references, causing restrict-qualified references to be treated the same as non-qualified ones. The fix ensures that the comparison now includes base and clique information, allowing the prepass to correctly prefer unrestricted variants when appropriate, improving the accuracy of SSA optimizations.

In Details

The vn_reference_eq function in tree-ssa-sccvn.cc now includes a comparison of the base and clique fields when lexically comparing VN references. This addresses a deficiency where restrict-qualified versus non-restrict-qualified references could be deemed equal. Consequently, the prefer function in tree-ssa-pre.cc can now correctly differentiate and select the unrestricted variant when a choice exists, impacting optimizations sensitive to pointer aliasing and memory access patterns.

For Context
SSA
Static Single Assignment. An intermediate representation in a compiler where every variable is assigned a value exactly once. This simplifies many optimization algorithms.
VN
Value Number. A unique identifier assigned to a distinct value within the SSA representation, used for equivalence checking.
prepass
A preliminary optimization pass that sets up or modifies data structures used by subsequent passes. In this context, it relates to SSA optimizations.
restrict
A keyword in C/C++ that acts as a type qualifier, informing the compiler that a pointer is the sole initial access path to the object it points to. This allows for more aggressive optimizations.
lexical comparison
A comparison of elements based on their order or position, as opposed to their semantic meaning. In this context, it refers to comparing the structure of VN references.
Filed Under: optimizationssacompiler