GCC Newspaper
JUNE 15, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
tree-ssa Performance Win

SSA Loop Optimizations: Store Motion Gets More Efficient

Refactors loop store motion code in GCC to avoid redundant checks and reduce memory usage.

The loop store motion pass in GCC’s tree-ssa optimizer has been micro-optimized. The ref_always_accessed_p function was refactored and renamed to ref_always_stored_p, saving storage and avoiding redundant checks at runtime. This tightens up the loop invariant code motion pass, which hoists stores that are loop-invariant out of the loop, improving performance.

In Details

This commit focuses on tree-ssa-loop-im.cc, specifically the loop store motion (LSM) pass. The ref_always_accessed_p function, used to determine if a memory reference is always accessed within a loop, is specialized for stores and renamed ref_always_stored_p. The stored_p field is removed from the ref_always_stored class because it's now known to always be true, reducing storage. This small cleanup improves efficiency within the loop optimization framework.

For Context

This commit improves GCC's ability to optimize loops, a fundamental part of program execution. Loop optimizations aim to reduce the number of instructions executed within a loop, leading to faster code. This commit specifically targets "store motion", where the compiler identifies memory writes that produce the same value on every loop iteration and moves that write outside the loop, eliminating redundant operations. The change simplifies the code and makes this optimization more efficient.

Filed Under: optimizationssaloopstore motion