GCC Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
i386 Performance Win

i386: Improve vector constant rematerialization in CSE

x86_cse now adds REG_EQUAL notes for vector constants, aiding LRA.

This commit enhances the Common Subexpression Elimination (CSE) pass for the i386 architecture. When CSE replaces a vector constant load with a copy of a vector set operation, it now adds a REG_EQUAL note. This note associates the copied constant vector with the original CONST_VECTOR operand, allowing the Late Register Allocation (LRA) pass to rematerialize the constant directly, rather than spilling the copy, which can improve code efficiency.

In Details

In x86_cse, when a CONST_VECTOR load is replaced by a vec_set operation, a REG_EQUAL note is added linking the result register of the vec_set to the original CONST_VECTOR operand. This allows LRA to recognize that the value is a constant and potentially avoid spilling the register holding the vec_set result, instead rematerializing the constant if needed. This improves constant propagation and register utilization for vector types.

For Context
i386
The original 32-bit Intel x86 architecture, often used as a baseline for x86-64.
x86_cse
Common Subexpression Elimination pass specifically for the x86 architecture within GCC.
vector constant
A constant value represented as a vector type, where multiple data elements are packed together.
REG_EQUAL note
A GCC internal note attached to a register, indicating that it holds a value equal to another operand, often used to help optimization passes.
LRA
Late Register Allocation, a phase in the compiler's backend responsible for assigning physical registers to virtual registers.
rematerialize
To recompute a value that was previously computed, rather than loading it from memory or a spilled register. This is often done for constants or simple expressions.
CONST_VECTOR
GCC's internal representation for a vector constant.
Filed Under: i386x86cseoptimizationregister allocation