cselim: Fix cond_store_replacement_limited for clobbers
Fixes `cond_store_replacement_limited` to correctly distinguish clobbers from stores, preventing incorrect phi argument usage.
The cond_store_replacement_limited function incorrectly treated clobber operations as stores. This led to erroneous usage of {CLOBBER(eos)} as a phi argument, causing incorrect code generation. This change corrects the function to properly identify and reject clobbers, ensuring they are not mistaken for stores.
In Details
The cond_store_replacement_limited function in tree-ssa-phiopt.cc is intended to replace conditional stores. It incorrectly identified CLOBBER statements as STORE operations. This resulted in cond_store_replacement_limited attempting to use a CLOBBER(eos) expression as an operand for a PHI node, which is semantically incorrect. The fix explicitly checks if an operation is a STORE and rejects CLOBBER operations, preventing them from being passed as phi arguments.
- cselim
- Common Subexpression Elimination (CSE) limited. A compiler optimization pass that identifies and eliminates redundant computations.
- Conditional store
- A store operation that is only performed if certain conditions are met. This is often implemented using conditional move instructions or predicated execution.
- Clobber
- An operation that indicates a variable or memory location's value is modified or invalidated, often by a function call or an intrinsic operation. It does not represent a specific value being written, but rather a side effect.
- PHI node
- In Static Single Assignment (SSA) form, a PHI node represents the merging of values from different control flow paths. It indicates which value a variable takes after a join point in the code.
- SSA (Static Single Assignment)
- An intermediate representation form used in compilers where every variable is assigned exactly once. This simplifies many optimization and analysis passes.