GCC Newspaper
JULY 29, 2026
Date
/
Architectures
Components
Topics
News & Policy
middle-end

Simplify atomic built-in handling.

Replaces INTEGER_CST + expand_normal with tree_to_uwhi for atomic operations.

GCC simplifies the handling of atomic operations by replacing the ‘INTEGER_CST + expand_normal’ pattern with a more efficient and readable approach using tree_fits_uwhi_p and tree_to_uwhi. This change targets the fold_builtin_atomic_always_lock_free function, improving code clarity and potentially reducing compiler overhead for atomic built-ins.

In Details

This commit refactors the implementation of fold_builtin_atomic_always_lock_free to replace a common pattern of handling integer constants. Instead of creating an INTEGER_CST and then expanding it with expand_normal, the code now uses tree_fits_uwhi_p to check if a constant fits within an unsigned wide integer and tree_to_uwhi to convert it. This simplifies the code and leverages more specialized tree-to-tree transformations.

For Context
atomic operation
An operation that is guaranteed to be performed in its entirety without interruption. In concurrent programming, atomics are essential for safely accessing shared data.
INTEGER_CST
A GCC internal representation (tree node type) for an integer constant.
expand_normal
A GCC internal function used to expand a given tree 'exp' into RTL (lower-level representation).
tree_fits_uwhi_p
A GCC internal function that checks if a tree value fits within an unsigned wide integer type.
tree_to_uwhi
A GCC internal function that converts a tree value to an unsigned wide integer type.
middle-end
The part of the compiler that performs optimizations and transformations on an intermediate representation (IR) of the code, after the frontend has parsed the source code and before the backend generates machine code.
Filed Under: optimizationatomic