x86 CSE drops redundant notes on constant integer loads
Common subexpression elimination on x86 now removes no longer needed REG_EQUAL/REG_EQUIV notes after constant integer loads.
This change refines common subexpression elimination (CSE) on x86 by removing redundant REG_EQUAL and REG_EQUIV notes. Previously, when a vector constant load was converted to a scalar integer load, the notes were left in place, causing issues with register allocation and constant pool handling. The fix ensures these notes are dropped when the source is replaced by a CONST_INT, preventing incorrect register equivalences and potential ICEs.
In Details
In x86 CSE, when replace_vector_const transforms a CONST_VECTOR into a CONST_INT, it uses gen_lowpart. If the original destination had a REG_EQUAL or REG_EQUIV note, it could be incorrectly associated with the new scalar destination. This patch correctly removes these notes when the destination becomes a bare REG, relying on the new CONST_INT source to establish the correct equivalence.
- Common Subexpression Elimination (CSE)
- A compiler optimization that identifies and eliminates redundant computations of the same expression. It replaces the recomputed expression with a temporary variable that stores the result of the first computation.
- REG_EQUAL/REG_EQUIV
- Notes attached to RTL expressions that indicate that two registers hold the same value or are equivalent. These are used by later optimization passes and register allocation.
- CONST_VECTOR
- An RTX (Representation Tree) mode representing a vector of constant values.
- CONST_INT
- An RTX mode representing an integer constant.
- RTX
- Representation Tree. GCC's internal intermediate representation for expressions and values, used for optimization and code generation.
- IRA
- Instruction Register Allocation. A GCC pass responsible for assigning physical registers to virtual registers (pseudo-registers).
- LRA
- Late Register Allocation. An alternative register allocator in GCC that operates later in the compilation pipeline.