https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124948

--- Comment #8 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-16 branch has been updated by Jakub Jelinek
<[email protected]>:

https://gcc.gnu.org/g:4a447fcedf50e3e6c0f26b02e1c21b674c473c21

commit r16-9288-g4a447fcedf50e3e6c0f26b02e1c21b674c473c21
Author: Jakub Jelinek <[email protected]>
Date:   Tue Jul 14 10:41:08 2026 +0200

    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  <[email protected]>

            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 <[email protected]>
    (cherry picked from commit deb5f74feeaf3a43f6d4008a1e01fc4d23c1efdf)

Reply via email to