2012-11-29  Yvan Roux  <yvan.roux@st.com>

	PR target/55942
	* optabs.c (expand_atomic_load): Condition the memory fence to the
	the right memory model.

diff --git a/gcc/optabs.c b/gcc/optabs.c
index 353727f..14956be 100644
--- a/gcc/optabs.c
+++ b/gcc/optabs.c
@@ -7478,12 +7478,13 @@ expand_atomic_load (rtx target, rtx mem, enum memmodel model)
     target = gen_reg_rtx (mode);
 
   /* Emit the appropriate barrier before the load.  */
-  expand_mem_thread_fence (model);
+  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)
+  /* For SEQ_CST or ACQUIRE, also emit a barrier after the load.  */
+  if (model == MEMMODEL_SEQ_CST || model == MEMMODEL_ACQUIRE)
     expand_mem_thread_fence (model);
 
   return target;
-- 
1.7.9.5

