@@ -155,6 +155,11 @@ (define_expand "atomic_load<mode>"
UNSPEC_LDA))]
""
{
+ enum memmodel model = memmodel_from_int (INTVAL (operands[2]));
+
+ if (is_mm_seq_cst (model))
+ expand_asm_memory_barrier ();
+
/* For DImode on 32-bit, we can use the FPU to perform the load. */
if (<MODE>mode == DImode && !TARGET_64BIT)
emit_insn (gen_atomic_loaddi_fpu
@@ -173,6 +178,8 @@ (define_expand "atomic_load<mode>"
if (dst != operands[0])
emit_move_insn (operands[0], dst);
}
+ if (!is_mm_relaxed (model))
+ expand_asm_memory_barrier ();
DONE;
})
new file mode 100644
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fno-tree-ter" } */
+/* { dg-final { scan-assembler-not "xorl\[\\t \]*\\\%eax,\[\\t \]*%eax" } } */
+
+int f(int *p, volatile _Bool *p1, _Atomic _Bool *p2)
+{
+ int v = *p;
+ *p1 = !v;
+ while (__atomic_load_n (p2, __ATOMIC_SEQ_CST));
+ return v - *p;
+}