GCC Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
gcc/ipa Performance Win

Fix optimization of up-level reference to array with negative low bound

Corrects optimization pass to properly handle array references with negative lower bounds.

An optimization pass (DSE) was incorrectly deleting stores to up-level array references that had negative lower bounds. This happened because IPA modref analysis inaccurately flagged these stores as dead. The issue stemmed from get_ref_base_and_extent incorrectly shrinking the maximum size of such arrays, causing the loss of elements. This fix ensures that array references with negative low bounds are handled correctly, preventing incorrect dead store elimination.

In Details

The Dynamic Stores Elimination (DSE) pass in GCC was incorrectly identifying stores to up-level array references with negative low bounds as dead. This was due to inaccuracies in the IPA ModRef analysis, specifically in the get_ref_base_and_extent function. This function would incorrectly shrink the perceived maximum size of arrays with negative low bounds, leading to the omission of elements like FRAME.19.s[0]. This commit corrects the get_ref_base_and_extent logic to accurately calculate array extents, thereby preventing DSE from erroneously deleting stores to these array elements.

For Context
DSE
Dynamic Stores Elimination. An optimization pass in GCC that identifies and removes stores to memory locations that are guaranteed not to be read later.
IPA modref
Interprocedural Analysis - Mod/Ref. Analyzes memory access (modifies/references) across function calls to enable optimizations. It determines which memory regions are potentially accessed by a function.
up-level reference
A reference to a variable or memory location that is in a scope outside the current one, typically a variable in an enclosing function or block. In this context, it refers to accessing an array declared in an outer scope.
negative low bound
In array declarations, the lower bound of the array's index range is negative. For example, array (-5..5) of int.
Filed Under: optimizationipaarray