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

Avoid-store-forwarding: Continue BB analysis after complex memory ops

The avoid-store-forwarding pass now continues analysis after encountering complex memory operations, potentially catching more optimization opportunities.

The avoid-store-forwarding pass in GCC previously stopped analyzing a basic block after encountering a complex memory operation. This change replaces the early return with a flush-and-continue, clearing pending store candidates and continuing the scan. This allows the pass to identify and exploit store-forwarding opportunities even after complex memory operations, potentially improving performance.

In Details

The avoid-store-forwarding pass optimizes memory operations within basic blocks. Previously, encountering a non-trivial store or load would halt analysis. This commit modifies store_forwarding_analyzer::avoid_store_forwarding to flush the pending store candidates and continue scanning, similar to the handling of throwing instructions and unknown-size memory operations. A toolchain developer outside this subsystem might not immediately realize the performance implications of prematurely terminating the analysis.

For Context

Store forwarding is a compiler optimization technique where a load instruction retrieves data directly from a previous store instruction, instead of from memory. This optimization improves performance by reducing memory accesses. This change enhances the compiler's ability to identify store-forwarding opportunities, even in the presence of complex memory operations within a basic block. A basic block is a sequence of instructions with a single entry and exit point. By continuing analysis after complex memory operations, the compiler can potentially discover more opportunities for store forwarding and generate more efficient code.

Filed Under: optimizationstore-forwardinggcc