GCC Newspaper
JUNE 15, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
x86_cse Performance Win

x86_cse: Check CONST0_RTX and CONSTM1_RTX During Vectorization

The x86 CSE pass now correctly handles CONST0_RTX and CONSTM1_RTX for constant vectors during vectorization, improving code generation.

This commit fixes an issue in the x86 common subexpression elimination (CSE) pass where CONST0_RTX and CONSTM1_RTX were not correctly handled for constant vectors. The fix ensures that during vectorization, redundant vector loads are properly replaced when the source is a constant vector of zeros or minus ones. This leads to better code generation by avoiding unnecessary computations.

In Details

The x86 backend's ix86_place_single_vector_set function in i386-features.cc now checks for CONST0_RTX with X86_CSE_CONST0_VECTOR and CONSTM1_RTX with X86_CSE_CONSTM1_VECTOR when the source is a constant vector. ix86_broadcast_inner sets the x86_cse kind accordingly. This fixes PR target/125239. The testsuite gcc.target/i386/pr124407-1.c was adjusted to match the expected CSE output.

For Context

Common subexpression elimination (CSE) is a compiler optimization that aims to eliminate redundant calculations. In the context of x86 vectorization, this means identifying and replacing repeated vector loads with a single load when the source is a constant vector (e.g., a vector of all zeros). This commit ensures that the CSE pass correctly recognizes and optimizes these scenarios, leading to more efficient code execution.

Filed Under: x86csevectorizationoptimization