diff mbox

[2/4,ARM,PR,target/65697,5.1] Backport stronger barriers for __sync,compare-and-swap builtins.

Message ID 55953954.8080302@foss.arm.com
State New
Headers show

Commit Message

Matthew Wahab July 2, 2015, 1:15 p.m. UTC
This patch backports the changes made to strengthen the barriers emitted for
the __sync compare-and-swap builtins.

The trunk patch submission is at
https://gcc.gnu.org/ml/gcc-patches/2015-06/msg01411.html
The commit is at https://gcc.gnu.org/ml/gcc-cvs/2015-06/msg01236.html

Tested the series for arm-none-linux-gnueabihf with check-gcc

Ok for the branch?
Matthew

2015-07-02  Matthew Wahab  <matthew.wahab@arm.com>

	Backport from trunk:
	2015-06-29  Matthew Wahab  <matthew.wahab@arm.com>

	PR target/65697
	* config/armc/arm.c (arm_split_compare_and_swap): For ARMv8,
	replace an initial acquire barrier with final barrier.
diff mbox

Patch

From fce96ded43d39847473b67e54e3146924c703f40 Mon Sep 17 00:00:00 2001
From: mwahab <mwahab@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Mon, 29 Jun 2015 16:09:10 +0000
Subject: [PATCH 2/4] 2015-07-01  Matthew Wahab  <matthew.wahab@arm.com>

	Backport
	PR target/65697
	* config/armc/arm.c (arm_split_compare_and_swap): For ARMv8, replace an
	initial acquire barrier with final barrier.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@225133 138bc75d-0d04-0410-961f-82ee72b054a4

Conflicts:
	gcc/ChangeLog

Change-Id: Ifab505d792d6227c7d2231813dfb2e7826f0f450
---
 gcc/config/arm/arm.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index b36dfb0..49005fb 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -27742,6 +27742,8 @@  arm_split_compare_and_swap (rtx operands[])
   scratch = operands[7];
   mode = GET_MODE (mem);
 
+  bool is_armv8_sync = arm_arch8 && is_mm_sync (mod_s);
+
   bool use_acquire = TARGET_HAVE_LDACQ
                      && !(is_mm_relaxed (mod_s) || is_mm_consume (mod_s)
 			  || is_mm_release (mod_s));
@@ -27750,6 +27752,11 @@  arm_split_compare_and_swap (rtx operands[])
                      && !(is_mm_relaxed (mod_s) || is_mm_consume (mod_s)
 			  || is_mm_acquire (mod_s));
 
+  /* For ARMv8, the load-acquire is too weak for __sync memory orders.  Instead,
+     a full barrier is emitted after the store-release.  */
+  if (is_armv8_sync)
+    use_acquire = false;
+
   /* Checks whether a barrier is needed and emits one accordingly.  */
   if (!(use_acquire || use_release))
     arm_pre_atomic_barrier (mod_s);
@@ -27790,7 +27797,8 @@  arm_split_compare_and_swap (rtx operands[])
     emit_label (label2);
 
   /* Checks whether a barrier is needed and emits one accordingly.  */
-  if (!(use_acquire || use_release))
+  if (is_armv8_sync
+      || !(use_acquire || use_release))
     arm_post_atomic_barrier (mod_s);
 
   if (is_mm_relaxed (mod_f))
-- 
1.9.1