GCC Newspaper
JUNE 15, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
avoid-store-forwarding Performance Win

Avoid-store-forwarding: Remove unnecessary store_exprs_del mechanism

The avoid-store-forwarding pass removes an unnecessary mechanism that caused O(n^2) behavior for large basic blocks.

The store_exprs_del vector in GCC’s avoid-store-forwarding pass was introduced as a safety measure but is no longer needed for correctness. Its removal simplifies the code and eliminates an O(n^2) scan, improving performance for large basic blocks. The vector tracked deleted store candidates and blocked forwarding when a deleted store’s range overlapped with the load, but the intended memory effects were already visible.

In Details

The store_exprs_del vector in store_forwarding_analyzer::avoid_store_forwarding is removed. This vector was a conservative measure added alongside the PR119795 fixes. It's now deemed unnecessary because the load reads all bytes from memory in the non-load-elimination path, and all bytes are covered by forwarded stores in the load-elimination path. The quadratic complexity arose from scanning this vector for each forwarding candidate. A toolchain developer might not immediately appreciate the performance impact on large basic blocks.

For Context

Store forwarding is a compiler optimization technique that reduces memory accesses by having a load instruction retrieve data directly from a previous store instruction. This commit removes an unnecessary check in the compiler's store-forwarding optimization, which simplifies the code and improves performance. The removed check was causing the compiler to take much longer to optimize code in some cases. This change makes the compiler faster and more efficient.

Filed Under: optimizationstore-forwardingperformancegcc