[Bug target/87206] Suboptimal code generation for __atomic_compare_exchange_n followed by a comparison

pinskia at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Dec 21 11:28:53 GMT 2021


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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement
   Last reconfirmed|                            |2021-12-21
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed.
Note GCC does produce better code than LLVM which produces two branches:

        mov     ecx, 1
        xor     eax, eax
        lock            cmpxchg dword ptr [rdi], ecx
        je      .LBB0_2
# %bb.1:
        test    eax, eax
        je      .LBB0_2
# %bb.3:
        jmp     bar                             # TAILCALL
.LBB0_2:
        ret


More information about the Gcc-bugs mailing list