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

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

https://gcc.gnu.org/g:2e6a851c6918089688179edc05583a03b4032972

commit r17-6690-g2e6a851c6918089688179edc05583a03b4032972
Author: Jakub Jelinek <[email protected]>
Date:   Wed Nov 25 17:56:04 2026 +0100

    c-family: Fix up atomic_bitint_fetch_using_cas_loop [PR128184]

    When implementing this function in GCC 14 for _BitInt it seems
    that for NAND I've implemented the GCC < 4.4 semantics.
    To quote the docs:
    @{ tmp = *ptr; *ptr = ~(tmp & value); return tmp; @}   // nand
    and
    @emph{Note:} GCC 4.4 and later implement @code{__sync_fetch_and_nand}
    as @code{*ptr = ~(tmp & value)} instead of @code{*ptr = ~tmp & value}.

    Fixed thusly.

    2026-11-25  Jakub Jelinek  <[email protected]>

            PR c/128184
            * c-common.cc (atomic_bitint_fetch_using_cas_loop): For
            __atomic_fetch_nand, __atomic_nand_fetch, __sync_fetch_and_nand
            and __sync_nand_and_fetch use ~(*ptr & value) rather than
            (~*ptr) & value.

            * gcc.dg/bitint-149.c: New test.

    Reviewed-by: Jeff Law <[email protected]>

Reply via email to