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

x86_cse: Add X86_CSE_CONST_VECTOR for native CONST_VECTOR.

GCC's x86 common subexpression elimination (CSE) now handles CONST_VECTOR and constant integer loads more efficiently.

This commit enhances GCC’s x86 common subexpression elimination (CSE) pass to better handle CONST_VECTORs. It introduces X86_CSE_CONST_VECTOR for native CONST_VECTORs, avoids dataflow (DF) chains by using CONST_VECTOR in REG_EQUAL notes, and preserves constant integer loads across function calls when beneficial. Additionally, it converts CONST_VECTOR loads (no larger than an integer register) to constant integer loads.

In Details

The x86 CSE pass identifies and eliminates redundant computations within a basic block. This commit adds the X86_CSE_CONST_VECTOR kind to x86_cse_kind in i386-features.cc to handle native CONST_VECTORs. It modifies ix86_place_single_vector_set to handle X86_CSE_CONST_VECTOR and generate SUBREG instructions for constant integer sources. ix86_broadcast_inner is updated to use CONST_VECTOR in REG_EQUAL notes and set the load kind to X86_CSE_CONST_VECTOR.

For Context

Common subexpression elimination (CSE) is a compiler optimization that avoids recomputing the same expression multiple times. If a calculation's inputs don't change, the compiler can store the result and reuse it. Vectors are arrays of data that can be processed with a single instruction. This commit improves GCC's x86 code generation by optimizing how constant vectors are handled during CSE, potentially leading to faster code execution.

Filed Under: x86optimizationcsevectorization