[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
- Re: [PATCH 15/27] target/s390x: Use tcg_gen_qemu_{ld,st}_i128 for LPQ, STPQ, (continued)
- [PATCH 17/27] target/s390x: Use cpu_{ld,st}*_mmu in do_csst, Richard Henderson, 2023/05/20
- [PATCH 20/27] accel/tcg: Remove prot argument to atomic_mmu_lookup, Richard Henderson, 2023/05/20
- [PATCH 21/27] accel/tcg: Eliminate #if on HAVE_ATOMIC128 and HAVE_CMPXCHG128, Richard Henderson, 2023/05/20
- [PATCH 22/27] qemu/atomic128: Split atomic16_read, Richard Henderson, 2023/05/20
- [PATCH 23/27] accel/tcg: Correctly use atomic128.h in ldst_atomicity.c.inc, Richard Henderson, 2023/05/20
- [PATCH 25/27] qemu/atomic128: Improve cmpxchg fallback for atomic16_set,
Richard Henderson <=
- [PATCH 18/27] target/s390x: Always use cpu_atomic_cmpxchgl_be_mmu in do_csst, 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 26/27] qemu/atomic128: Add runtime test for FEAT_LSE2, Richard Henderson, 2023/05/20