Support constants for cond_store_replacement_limited
Improve constant handling in conditional store replacement for better optimization.
The conditional store replacement pass (cond_store_replacement_limited) now supports constants for stores, extending its capabilities beyond just SSA names. This change allows the optimization to handle more cases, similar to the full cselim pass, by rejecting clobbers instead of restricting replacements to SSA names or specific invariants. This should enable better optimization for code involving constants in conditional stores.
In Details
The cond_store_replacement_limited pass in tree-ssa-phiopt.cc previously restricted replacements to SSA names. This commit broadens its scope to include GIMPLE invariants and rejects clobbers, aligning its behavior with the more general cselim pass. This allows for more aggressive constant propagation and elimination in conditional store operations within the SSA optimiser.
- cond_store_replacement_limited
- A GCC optimization pass that attempts to replace conditional stores with simpler instructions, improving code efficiency. It operates on the GIMPLE Intermediate Representation.
- SSA name
- In Static Single Assignment (SSA) form, each variable is assigned a unique name whenever it is assigned a value. This simplifies analysis and optimization by ensuring each variable has only one definition.
- GIMPLE
- GNU Intermediate Representation, a three-address code form used by GCC after the initial parsing and before machine code generation. It's designed for easier optimization.
- cselim
- Common Subexpression Elimination (CSE) pass in GCC, which identifies and eliminates redundant computations. The limited version (
cond_store_replacement_limited) is a specialized form focused on conditional stores. - clobbers
- In compiler optimization, a 'clobber' refers to a value that is overwritten or destroyed by an instruction. Recognizing clobbers is important for dead code elimination and register allocation.