From: Ivan Maidanski Date: Tue, 5 Apr 2016 21:10:56 +0000 (+0300) Subject: Eliminate redundant lwsync 2nd call in CAS_full on fail (gcc/PowerPC) X-Git-Tag: v7.6.0~225 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=157e8ad79a1bcc3d0ab331ab2217a9b81f35864c;p=libatomic_ops 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. --- 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