[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 25/27] qemu/atomic128: Improve cmpxchg fallback for atomic16_s
|
From: |
Richard Henderson |
|
Subject: |
[PATCH v2 25/27] qemu/atomic128: Improve cmpxchg fallback for atomic16_set |
|
Date: |
Tue, 23 May 2023 06:47:31 -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 v2 21/27] accel/tcg: Eliminate #if on HAVE_ATOMIC128 and HAVE_CMPXCHG128, (continued)
- [PATCH v2 21/27] accel/tcg: Eliminate #if on HAVE_ATOMIC128 and HAVE_CMPXCHG128, Richard Henderson, 2023/05/23
- [PATCH v2 20/27] accel/tcg: Remove prot argument to atomic_mmu_lookup, Richard Henderson, 2023/05/23
- [PATCH v2 22/27] qemu/atomic128: Split atomic16_read, Richard Henderson, 2023/05/23
- [PATCH v2 24/27] tcg: Split out tcg/debug-assert.h, Richard Henderson, 2023/05/23
- [PATCH v2 23/27] accel/tcg: Correctly use atomic128.h in ldst_atomicity.c.inc, Richard Henderson, 2023/05/23
- [PATCH v2 25/27] qemu/atomic128: Improve cmpxchg fallback for atomic16_set,
Richard Henderson <=
- [PATCH v2 26/27] qemu/atomic128: Add runtime test for FEAT_LSE2, Richard Henderson, 2023/05/23
- [PATCH v2 27/27] qemu/atomic128: Add x86_64 atomic128-ldst.h, Richard Henderson, 2023/05/23