diff options
Diffstat (limited to 'gcc/optabs-query.c')
-rw-r--r-- | gcc/optabs-query.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/gcc/optabs-query.c b/gcc/optabs-query.c index 7cff5cc508..4899333096 100644 --- a/gcc/optabs-query.c +++ b/gcc/optabs-query.c @@ -1,5 +1,5 @@ /* IR-agnostic target query functions relating to optabs - Copyright (C) 1987-2016 Free Software Foundation, Inc. + Copyright (C) 1987-2017 Free Software Foundation, Inc. This file is part of GCC. @@ -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 |