gnu/gcc/deb5f74feeaf3a43f6d4008a1e01fc4d23c1efdf c-family: Use CAS loop instead of RMW atomics on small _BitInt with padding on targets which need to extend [PR124948]
Some atomic/sync builtins don't sign or zero extend _BitInt values
with padding in it.
IMNSHO this is solely about some of the type-generic atomic/sync builtins
(those documented to take TYPE * arguments) and needs to be handled in the
FE, likely in gcc/c-family/c-common.cc (resolve_overloaded_builtin).
There already is code to transform various type-generic builtins into a CAS
loop for say unsigned _BitInt(253), so I think it should be used also for
the case where the type is BITINT_TYPE with any padding bits in the
extend other than bitint_ext_undef mode.
2026-07-14 Jakub Jelinek <jakub@redhat.com>
PR target/124948
* c-common.cc (sync_resolve_size): Return -1 for fetch ops
on _BitInt types with padding bits where the target requires
extension into the padding bits.
(atomic_bitint_fetch_using_cas_loop): Handle also __sync_*
fetch builtins.
* gcc.dg/torture/bitint-100.c: New test.
Reviewed-by: Richard Biener <rguenth@suse.de>
2 files changed