From 157e8ad79a1bcc3d0ab331ab2217a9b81f35864c Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Wed, 6 Apr 2016 00:10:56 +0300 Subject: [PATCH] Eliminate redundant lwsync 2nd call in CAS_full on fail (gcc/PowerPC) * src/atomic_ops/sysdeps/gcc/powerpc.h (AO_compare_and_swap_full, AO_fetch_compare_and_swap_full): Do not call AO_lwsync 2nd time if CAS is not successful. --- src/atomic_ops/sysdeps/gcc/powerpc.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/atomic_ops/sysdeps/gcc/powerpc.h b/src/atomic_ops/sysdeps/gcc/powerpc.h index 94e83e7..5bee475 100644 --- a/src/atomic_ops/sysdeps/gcc/powerpc.h +++ b/src/atomic_ops/sysdeps/gcc/powerpc.h @@ -227,7 +227,8 @@ AO_test_and_set_full(volatile AO_TS_t *addr) { int result; AO_lwsync(); result = AO_compare_and_swap(addr, old, new_val); - AO_lwsync(); + if (result) + AO_lwsync(); return result; } # define AO_HAVE_compare_and_swap_full @@ -291,7 +292,8 @@ AO_fetch_compare_and_swap_full(volatile AO_t *addr, AO_t old_val, AO_t result; AO_lwsync(); result = AO_fetch_compare_and_swap(addr, old_val, new_val); - AO_lwsync(); + if (result == old_val) + AO_lwsync(); return result; } #define AO_HAVE_fetch_compare_and_swap_full -- 2.50.1