GCC Newspaper
JULY 29, 2026
Date
/
Architectures
Components
Topics
News & Policy
cselib

32-bit hash restored for cselib values

GCC restores a 32-bit hash for cselib values, resolving a bug that caused lookups to fail by relocating the UID field.

GCC restores the hash used in the common subexpression elimination library (cselib) to 32 bits, fixing a bug where trimming the hash to 30 bits caused zero values to be returned, leading to lookup failures. The space for the 32-bit hash is reclaimed by moving the UID field to a different RTX union member, simplifying some operations while slightly complicating others.

In Details

cselib_val::hash was shrunk to 30 bits, colliding with cselib_hash_rtx using 0 as an error sentinel. This commit restores it to 32 bits, moving cselib_val::uid to rtx_def::u2 to reclaim space. This change simplifies the hash lookup logic and avoids false negatives when values are created. It assumes a 1:1 mapping of VALUEs to cselib_vals.

For Context
cselib
The Common Subexpression Elimination library in GCC, which identifies and eliminates redundant computations within the compiler's intermediate representation.
RTX
Register Transfer language, GCC's internal intermediate representation used to describe code operations before they are translated to machine instructions.
hash
A function that computes a fixed-size value (the hash) from an input, used here to quickly identify and retrieve common subexpression values within the cselib.
UID
Unique Identifier, used here to distinguish different cselib values.
Filed Under: cseliboptimizationbugfix