Re: Strange asm generated by GCC...

Liste des GroupesRevenir à c arch 
Sujet : Re: Strange asm generated by GCC...
De : jseigh_es00 (at) *nospam* xemaps.com (jseigh)
Groupes : comp.arch
Date : 20. Dec 2024, 20:59:36
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vk4ib8$3jn8h$1@dont-email.me>
References : 1 2
User-Agent : Mozilla Thunderbird
On 12/20/24 12:46, jseigh wrote:
On 12/19/24 19:43, Chris M. Thomasson wrote:
Why in the world would GCC use an XCHG instruction for the following code. The damn XCHG has an implied LOCK prefix! Yikes!
>
 Speaking of strange code
 
That should be a ref paramter.  I though I updated the pasted code.
#include <atomic>
bool test1(std::atomic<int>& var, int addend)
{
     int expected = var.load(std::memory_order_relaxed);
     int update = expected + addend;
     return var.compare_exchange_weak(expected, update, std::memory_order_acq_rel, std::memory_order_seq_cst);
}
test1(std::atomic<int>&, int):                 // @test1(std::atomic<int>&, int)
         ldr     w8, [x0]
         ldaxr   w9, [x0]
         cmp     w9, w8
         b.ne    .LBB0_3
         add     w8, w8, w1
         stlxr   w9, w8, [x0]
         cbz     w9, .LBB0_4
         mov     w0, wzr
         ret
.LBB0_3:
         clrex
         mov     w0, wzr
         ret
.LBB0_4:
         mov     w0, #1
         ret

Date Sujet#  Auteur
20 Dec01:43 * Strange asm generated by GCC...11Chris M. Thomasson
20 Dec01:54 +- Re: Strange asm generated by GCC...1Chris M. Thomasson
20 Dec02:02 +* Re: Strange asm generated by GCC...5Chris M. Thomasson
20 Dec12:55 i`* Re: Strange asm generated by GCC...4jseigh
20 Dec21:12 i `* Re: Strange asm generated by GCC...3Chris M. Thomasson
20 Dec21:15 i  +- Re: Strange asm generated by GCC...1Chris M. Thomasson
20 Dec21:23 i  `- Re: Strange asm generated by GCC...1Chris M. Thomasson
20 Dec18:46 `* Re: Strange asm generated by GCC...4jseigh
20 Dec20:59  +* Re: Strange asm generated by GCC...2jseigh
20 Dec21:17  i`- Re: Strange asm generated by GCC...1jseigh
21 Dec11:37  `- Re: Strange asm generated by GCC...1aph

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal