re PR target/65697 (__atomic memory barriers not strong enough for __sync builtins)
authorMatthew Wahab <matthew.wahab@arm.com>
Mon, 1 Jun 2015 15:24:37 +0000 (15:24 +0000)
committerMatthew Wahab <mwahab@gcc.gnu.org>
Mon, 1 Jun 2015 15:24:37 +0000 (15:24 +0000)
PR target/65697
* gcc.target/aarch64/sync-comp-swap.c: New.
* gcc.target/aarch64/sync-comp-swap.x: New.
* gcc.target/aarch64/sync-op-acquire.c: New.
* gcc.target/aarch64/sync-op-acquire.x: New.
* gcc.target/aarch64/sync-op-full.c: New.
* gcc.target/aarch64/sync-op-full.x: New.
* gcc.target/aarch64/sync-op-release.c: New.
* gcc.target/aarch64/sync-op-release.x: New.

From-SVN: r223986

gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/aarch64/sync-comp-swap.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/sync-comp-swap.x [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/sync-op-acquire.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/sync-op-acquire.x [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/sync-op-full.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/sync-op-full.x [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/sync-op-release.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/sync-op-release.x [new file with mode: 0644]

index 643d0500d74b3ed9d9ea56e3219759e81968b069..076f164f6ebc2e1731449dd357f5a93cba7d8ea2 100644 (file)
@@ -1,3 +1,15 @@
+2015-06-01  Matthew Wahab  <matthew.wahab@arm.com>
+
+       PR target/65697
+       * gcc.target/aarch64/sync-comp-swap.c: New.
+       * gcc.target/aarch64/sync-comp-swap.x: New.
+       * gcc.target/aarch64/sync-op-acquire.c: New.
+       * gcc.target/aarch64/sync-op-acquire.x: New.
+       * gcc.target/aarch64/sync-op-full.c: New.
+       * gcc.target/aarch64/sync-op-full.x: New.
+       * gcc.target/aarch64/sync-op-release.c: New.
+       * gcc.target/aarch64/sync-op-release.x: New.
+
 2015-06-01  Alex Velenko  <Alex.Velenko@arm.com>
 
         * gcc.target/arm/thumb-ltu.c (foo): Predefined.
diff --git a/gcc/testsuite/gcc.target/aarch64/sync-comp-swap.c b/gcc/testsuite/gcc.target/aarch64/sync-comp-swap.c
new file mode 100644 (file)
index 0000000..126b997
--- /dev/null
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fno-ipa-icf" } */
+
+#include "sync-comp-swap.x"
+
+/* { dg-final { scan-assembler-times "ldxr\tw\[0-9\]+, \\\[x\[0-9\]+\\\]" 2 } } */
+/* { dg-final { scan-assembler-times "stlxr\tw\[0-9\]+, w\[0-9\]+, \\\[x\[0-9\]+\\\]" 2 } } */
+/* { dg-final { scan-assembler-times "dmb\tish" 2 } } */
diff --git a/gcc/testsuite/gcc.target/aarch64/sync-comp-swap.x b/gcc/testsuite/gcc.target/aarch64/sync-comp-swap.x
new file mode 100644 (file)
index 0000000..eda52e4
--- /dev/null
@@ -0,0 +1,13 @@
+int v = 0;
+
+int
+sync_bool_compare_swap (int a, int b)
+{
+  return __sync_bool_compare_and_swap (&v, &a, &b);
+}
+
+int
+sync_val_compare_swap (int a, int b)
+{
+  return __sync_val_compare_and_swap (&v, &a, &b);
+}
diff --git a/gcc/testsuite/gcc.target/aarch64/sync-op-acquire.c b/gcc/testsuite/gcc.target/aarch64/sync-op-acquire.c
new file mode 100644 (file)
index 0000000..2639f9f
--- /dev/null
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+#include "sync-op-acquire.x"
+
+/* { dg-final { scan-assembler-times "ldxr\tw\[0-9\]+, \\\[x\[0-9\]+\\\]" 1 } } */
+/* { dg-final { scan-assembler-times "stxr\tw\[0-9\]+, w\[0-9\]+, \\\[x\[0-9\]+\\\]" 1 } } */
+/* { dg-final { scan-assembler-times "dmb\tish" 1 } } */
diff --git a/gcc/testsuite/gcc.target/aarch64/sync-op-acquire.x b/gcc/testsuite/gcc.target/aarch64/sync-op-acquire.x
new file mode 100644 (file)
index 0000000..4c4548c
--- /dev/null
@@ -0,0 +1,7 @@
+int v;
+
+int
+sync_lock_test_and_set (int a)
+{
+  return __sync_lock_test_and_set (&v, a);
+}
diff --git a/gcc/testsuite/gcc.target/aarch64/sync-op-full.c b/gcc/testsuite/gcc.target/aarch64/sync-op-full.c
new file mode 100644 (file)
index 0000000..10fc8fc
--- /dev/null
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+#include "sync-op-full.x"
+
+/* { dg-final { scan-assembler-times "ldxr\tw\[0-9\]+, \\\[x\[0-9\]+\\\]" 12 } } */
+/* { dg-final { scan-assembler-times "stlxr\tw\[0-9\]+, w\[0-9\]+, \\\[x\[0-9\]+\\\]" 12 } } */
+/* { dg-final { scan-assembler-times "dmb\tish" 12 } } */
diff --git a/gcc/testsuite/gcc.target/aarch64/sync-op-full.x b/gcc/testsuite/gcc.target/aarch64/sync-op-full.x
new file mode 100644 (file)
index 0000000..c24223d
--- /dev/null
@@ -0,0 +1,73 @@
+int v = 0;
+
+int
+sync_fetch_and_add (int a)
+{
+  return __sync_fetch_and_add (&v, a);
+}
+
+int
+sync_fetch_and_sub (int a)
+{
+  return __sync_fetch_and_sub (&v, a);
+}
+
+int
+sync_fetch_and_and (int a)
+{
+  return __sync_fetch_and_and (&v, a);
+}
+
+int
+sync_fetch_and_nand (int a)
+{
+  return __sync_fetch_and_nand (&v, a);
+}
+
+int
+sync_fetch_and_xor (int a)
+{
+  return __sync_fetch_and_xor (&v, a);
+}
+
+int
+sync_fetch_and_or (int a)
+{
+  return __sync_fetch_and_or (&v, a);
+}
+
+int
+sync_add_and_fetch (int a)
+{
+  return __sync_add_and_fetch (&v, a);
+}
+
+int
+sync_sub_and_fetch (int a)
+{
+  return __sync_sub_and_fetch (&v, a);
+}
+
+int
+sync_and_and_fetch (int a)
+{
+  return __sync_and_and_fetch (&v, a);
+}
+
+int
+sync_nand_and_fetch (int a)
+{
+  return __sync_nand_and_fetch (&v, a);
+}
+
+int
+sync_xor_and_fetch (int a)
+{
+  return __sync_xor_and_fetch (&v, a);
+}
+
+int
+sync_or_and_fetch (int a)
+{
+  return __sync_or_and_fetch (&v, a);
+}
diff --git a/gcc/testsuite/gcc.target/aarch64/sync-op-release.c b/gcc/testsuite/gcc.target/aarch64/sync-op-release.c
new file mode 100644 (file)
index 0000000..d25b46f
--- /dev/null
@@ -0,0 +1,6 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+#include "sync-op-release.x"
+
+/* { dg-final { scan-assembler-times "stlr" 1 } } */
diff --git a/gcc/testsuite/gcc.target/aarch64/sync-op-release.x b/gcc/testsuite/gcc.target/aarch64/sync-op-release.x
new file mode 100644 (file)
index 0000000..704bcff
--- /dev/null
@@ -0,0 +1,7 @@
+int v;
+
+void
+sync_lock_release (void)
+{
+  __sync_lock_release (&v);
+}