diff options
Diffstat (limited to 'gcc/optabs.c')
-rw-r--r-- | gcc/optabs.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/gcc/optabs.c b/gcc/optabs.c index fd353d7e627..91b4661090d 100644 --- a/gcc/optabs.c +++ b/gcc/optabs.c @@ -7700,14 +7700,14 @@ expand_atomic_load (rtx target, rtx mem, enum memmodel model) if (!target || target == const0_rtx) target = gen_reg_rtx (mode); - /* Emit the appropriate barrier before the load. */ - expand_mem_thread_fence (model); + /* For SEQ_CST, emit a barrier before the load. */ + if (model == MEMMODEL_SEQ_CST) + expand_mem_thread_fence (model); emit_move_insn (target, mem); - /* For SEQ_CST, also emit a barrier after the load. */ - if (model == MEMMODEL_SEQ_CST) - expand_mem_thread_fence (model); + /* Emit the appropriate barrier after the load. */ + expand_mem_thread_fence (model); return target; } @@ -7768,13 +7768,12 @@ expand_atomic_store (rtx mem, rtx val, enum memmodel model, bool use_release) return NULL_RTX; } - /* If there is no mem_store, default to a move with barriers */ - if (model == MEMMODEL_SEQ_CST || model == MEMMODEL_RELEASE) - expand_mem_thread_fence (model); + /* Otherwise assume stores are atomic, and emit the proper barriers. */ + expand_mem_thread_fence (model); emit_move_insn (mem, val); - /* For SEQ_CST, also emit a barrier after the load. */ + /* For SEQ_CST, also emit a barrier after the store. */ if (model == MEMMODEL_SEQ_CST) expand_mem_thread_fence (model); |