[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 25/27] qemu/atomic128: Improve cmpxchg fallback for atomic16_set
|
From: |
Richard Henderson |
|
Subject: |
[PATCH 25/27] qemu/atomic128: Improve cmpxchg fallback for atomic16_set |
|
Date: |
Sat, 20 May 2023 09:26:32 -0700 |
Use __sync_bool_compare_and_swap_16 to control the loop,
rather than a separate comparison.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
host/include/generic/host/atomic128-ldst.h | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/host/include/generic/host/atomic128-ldst.h
b/host/include/generic/host/atomic128-ldst.h
index 79d208b7a4..80fff0643a 100644
--- a/host/include/generic/host/atomic128-ldst.h
+++ b/host/include/generic/host/atomic128-ldst.h
@@ -58,11 +58,14 @@ atomic16_read_rw(Int128 *ptr)
static inline void ATTRIBUTE_ATOMIC128_OPT
atomic16_set(Int128 *ptr, Int128 val)
{
- Int128 old = *ptr, cmp;
+ __int128_t *ptr_align = __builtin_assume_aligned(ptr, 16);
+ __int128_t old;
+ Int128Alias new;
+
+ new.s = val;
do {
- cmp = old;
- old = atomic16_cmpxchg(ptr, cmp, val);
- } while (int128_ne(old, cmp));
+ old = *ptr_align;
+ } while (!__sync_bool_compare_and_swap_16(ptr_align, old, new.i));
}
#else
--
2.34.1
- [PATCH 22/27] qemu/atomic128: Split atomic16_read, (continued)
- [PATCH 22/27] qemu/atomic128: Split atomic16_read, Richard Henderson, 2023/05/20
- [PATCH 16/27] accel/tcg: Unify cpu_{ld,st}*_{be,le}_mmu, Richard Henderson, 2023/05/20
- Re: [PATCH 16/27] accel/tcg: Unify cpu_{ld,st}*_{be,le}_mmu, Philippe Mathieu-Daudé, 2023/05/21
- Re: [PATCH 16/27] accel/tcg: Unify cpu_{ld,st}*_{be,le}_mmu, Richard Henderson, 2023/05/21
- Re: [PATCH 16/27] accel/tcg: Unify cpu_{ld,st}*_{be,le}_mmu, Philippe Mathieu-Daudé, 2023/05/22
- Re: [PATCH 16/27] accel/tcg: Unify cpu_{ld,st}*_{be,le}_mmu, Richard Henderson, 2023/05/22
[PATCH 23/27] accel/tcg: Correctly use atomic128.h in ldst_atomicity.c.inc, Richard Henderson, 2023/05/20
[PATCH 24/27] tcg: Split out tcg/debug-assert.h, Richard Henderson, 2023/05/20
[PATCH 27/27] qemu/atomic128: Add x86_64 atomic128-ldst.h, Richard Henderson, 2023/05/20
[PATCH 25/27] qemu/atomic128: Improve cmpxchg fallback for atomic16_set,
Richard Henderson <=
[PATCH 26/27] qemu/atomic128: Add runtime test for FEAT_LSE2, Richard Henderson, 2023/05/20
[PATCH 11/27] include/host: Split out atomic128-ldst.h, Richard Henderson, 2023/05/20