diff options
author | Torvald Riegel <torvald@gcc.gnu.org> | 2017-02-01 17:21:59 +0000 |
---|---|---|
committer | Torvald Riegel <torvald@gcc.gnu.org> | 2017-02-01 17:21:59 +0000 |
commit | 969a32ce9354585f5f2b89df2e025f52eb0e1644 (patch) | |
tree | ba5dc4787f7d4f9d23224810508207f4fcc188dc /gcc/optabs-query.c | |
parent | 55e75c7c6bcfe386d0ecbf4611cff81040af00b3 (diff) | |
download | gcc-969a32ce9354585f5f2b89df2e025f52eb0e1644.zip gcc-969a32ce9354585f5f2b89df2e025f52eb0e1644.tar.gz gcc-969a32ce9354585f5f2b89df2e025f52eb0e1644.tar.bz2 |
Fix __atomic to not implement atomic loads with CAS.
gcc/
* builtins.c (fold_builtin_atomic_always_lock_free): Make "lock-free"
conditional on existance of a fast atomic load.
* optabs-query.c (can_atomic_load_p): New function.
* optabs-query.h (can_atomic_load_p): Declare it.
* optabs.c (expand_atomic_exchange): Always delegate to libatomic if
no fast atomic load is available for the particular size of access.
(expand_atomic_compare_and_swap): Likewise.
(expand_atomic_load): Likewise.
(expand_atomic_store): Likewise.
(expand_atomic_fetch_op): Likewise.
* testsuite/lib/target-supports.exp
(check_effective_target_sync_int_128): Remove x86 because it provides
no fast atomic load.
(check_effective_target_sync_int_128_runtime): Likewise.
libatomic/
* acinclude.m4: Add #define FAST_ATOMIC_LDST_*.
* auto-config.h.in: Regenerate.
* config/x86/host-config.h (FAST_ATOMIC_LDST_16): Define to 0.
(atomic_compare_exchange_n): New.
* glfree.c (EXACT, LARGER): Change condition and add comments.
From-SVN: r245098
Diffstat (limited to 'gcc/optabs-query.c')
-rw-r--r-- | gcc/optabs-query.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/gcc/optabs-query.c b/gcc/optabs-query.c index 6c34a4e..4899333 100644 --- a/gcc/optabs-query.c +++ b/gcc/optabs-query.c @@ -584,6 +584,25 @@ can_atomic_exchange_p (machine_mode mode, bool allow_libcall) return can_compare_and_swap_p (mode, allow_libcall); } +/* Return true if an atomic load can be performed without falling back to + a compare-and-swap. */ + +bool +can_atomic_load_p (machine_mode mode) +{ + enum insn_code icode; + + /* Does the target supports the load directly? */ + icode = direct_optab_handler (atomic_load_optab, mode); + if (icode != CODE_FOR_nothing) + return true; + + /* If the size of the object is greater than word size on this target, + then we assume that a load will not be atomic. Also see + expand_atomic_load. */ + return GET_MODE_PRECISION (mode) <= BITS_PER_WORD; +} + /* Determine whether "1 << x" is relatively cheap in word_mode. */ bool |