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

Tree optimization: Avoid redundant store skipping on same-value stores

Fixes redundant store elimination to avoid skipping stores with identical values, preventing incorrect code.

This commit addresses issues in the Value Numbering (VN) based redundant store elimination pass by preventing it from skipping stores that write the same value. Previously, the optimization incorrectly skipped such stores when searching for redundant earlier stores, leading to incorrect code generation. The fix ensures that same-value stores are not skipped during redundant store elimination and are handled correctly during hash table insertions, resolving incorrect optimizations in test cases like pr91091-2.c.

In Details

The tree-ssa-sccvn.cc implementation of Value Numbering (VN) for redundant store elimination had a flaw where it would skip stores with identical values (same-val may-defs). This behavior interfered with correctly identifying redundant stores and also impacted hash table insertions in vn_walk_cb_data::finish. This change modifies vn_reference_lookup_3 to avoid skipping these same-value stores when performing redundant store elimination and adjusts vn_walk_cb_data::finish to handle the hash table insertion correctly. These changes resolve incorrect optimizations related to redundant…

For Context
Value Numbering (VN)
An optimization technique that assigns a unique number (value number) to expressions that compute the same value, allowing the compiler to eliminate redundant computations.
redundant store elimination
An optimization pass that removes store operations to memory if the value being stored is identical to a value already stored in the same location, and no intervening memory operations have occurred.
tree-ssa-sccvn.cc
A GCC source file containing the implementation of the Sparse Conditional Constant Propagation and Value Numbering (SCCVN) optimization pass, which operates on the SSA representation of GIMPLE.
may-defs
In optimization analysis, 'may-defs' refers to potential definitions (writes) to memory locations. 'Same-val may-defs' specifically indicates that the value being written is identical across these potential definitions.
Filed Under: optimizationcompiler bugmemory optimization