GCC Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
rs6000

Fix type size checks for __builtin_ppc_atomic_cas_local

Corrected type size validation for PowerPC atomic compare-and-swap builtin.

This patch addresses several issues in the __builtin_ppc_atomic_cas_local intrinsic for the PowerPC rs6000 target. It introduces necessary type size checks for the first three operands, ensuring they are of the same size and not function pointers. Additionally, it handles cases where the 128-bit quad-memory-atomic option is disabled but 128-bit operands are used, and resolves an ICE that occurred when the builtin was not assigned to a left-hand side by adding a check to allocate a register RTX if the target is null.

In Details

This commit fixes several omissions in the rs6000_expand_builtin function for __builtin_ppc_atomic_cas_local. It adds checks to ensure the first three operands have matching sizes, disallows function pointers, and errors out if -mno-quad-memory-atomic is used with 128-bit operands. It also adds a check for a null target RTX, preventing an ICE in emit_cmp_and_jump_insns by allocating a reg_rtx when necessary.

For Context
__builtin_ppc_atomic_cas_local
A GCC intrinsic function providing atomic compare-and-swap functionality for local memory on PowerPC processors.
rs6000
GCC's target architecture name for IBM's PowerPC processors.
intrinsic function
A function whose implementation is provided directly by the compiler, often mapping to specific machine instructions.
RTX
Representation of intermediate code in GCC, a symbolic, address-like structure used internally by the compiler.
ICE
Internal Compiler Error, a crash within the compiler itself indicating a bug in the compiler's logic.
Filed Under: powerpcatomiccompiler