GCC Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
phiopt/cselim

phiopt/cselim: Allow load between conditional store replacement.

Enables conditional store replacement even with a load between the store and the condition.

This commit enhances the cond_store_replacement_limited pass in GCC’s phiopt/cselim optimization. It now allows a load instruction to exist between a conditional store and the condition that guards it. Previously, such loads were rejected, preventing the optimization. The change enables more aggressive conditional store elimination, potentially reducing code size by replacing conditional stores with unconditional ones, with Dead Store Elimination (DSE) handling further cleanup.

In Details

In tree-ssa-phiopt.cc, cond_store_replacement_limited now permits a load instruction after the conditional store to be replaced. Previously, any load after the store would cause the replacement to be rejected. This change allows more general conditional stores to be converted into unconditional stores, relying on DSE to remove redundant stores, thereby improving optimization effectiveness.

For Context
phiopt/cselim
A GCC optimization pass that performs conditional select elimination and related optimizations, aiming to simplify code by removing conditional branches or stores where possible.
load
An instruction that reads data from memory into a processor register.
store
An instruction that writes data from a processor register to memory.
Dead Store Elimination (DSE)
An optimization pass that removes stores to memory locations whose values are never subsequently read.
Filed Under: optimizationphioptcselimconditional store