public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/c++-modules] aarch64: Fix up __aarch64_cas16_acq_rel fallback
@ 2020-08-04 17:36 Nathan Sidwell
  0 siblings, 0 replies; only message in thread
From: Nathan Sidwell @ 2020-08-04 17:36 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:90b43856fdff7d96d93d22970eca8a86c56e0ddc

commit 90b43856fdff7d96d93d22970eca8a86c56e0ddc
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Mon Aug 3 22:55:28 2020 +0200

    aarch64: Fix up __aarch64_cas16_acq_rel fallback
    
    As mentioned in the PR, the fallback path when LSE is unavailable writes
    incorrect registers to the memory if the previous content compares equal
    to x0, x1 - it writes copy of x0, x1 from the start of function, but it
    should write x2, x3.
    
    2020-08-03  Jakub Jelinek  <jakub@redhat.com>
    
            PR target/96402
            * config/aarch64/lse.S (__aarch64_cas16_acq_rel): Use x2, x3 instead
            of x(tmp0), x(tmp1) in STXP arguments.
    
            * gcc.target/aarch64/pr96402.c: New test.

Diff:
---
 gcc/testsuite/gcc.target/aarch64/pr96402.c | 16 ++++++++++++++++
 libgcc/config/aarch64/lse.S                |  2 +-
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/gcc/testsuite/gcc.target/aarch64/pr96402.c b/gcc/testsuite/gcc.target/aarch64/pr96402.c
new file mode 100644
index 00000000000..fa2dddfac15
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/pr96402.c
@@ -0,0 +1,16 @@
+/* PR target/96402 */
+/* { dg-do run { target int128 } } */
+/* { dg-options "-moutline-atomics" } */
+
+int
+main ()
+{
+  __int128 a = 0;
+  __sync_val_compare_and_swap (&a, (__int128) 0, (__int128) 1);
+  if (a != 1)
+    __builtin_abort ();
+  __sync_val_compare_and_swap (&a, (__int128) 1, (((__int128) 0xdeadbeeffeedbac1ULL) << 64) | 0xabadcafe00c0ffeeULL);
+  if (a != ((((__int128) 0xdeadbeeffeedbac1ULL) << 64) | 0xabadcafe00c0ffeeULL))
+    __builtin_abort ();
+  return 0;
+}
diff --git a/libgcc/config/aarch64/lse.S b/libgcc/config/aarch64/lse.S
index aa3e3dc4f2d..7496b8b6337 100644
--- a/libgcc/config/aarch64/lse.S
+++ b/libgcc/config/aarch64/lse.S
@@ -203,7 +203,7 @@ STARTFN	NAME(cas)
 	cmp		x0, x(tmp0)
 	ccmp		x1, x(tmp1), #0, eq
 	bne		1f
-	STXP		w(tmp2), x(tmp0), x(tmp1), [x4]
+	STXP		w(tmp2), x2, x3, [x4]
 	cbnz		w(tmp2), 0b
 1:	ret


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-08-04 17:36 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-04 17:36 [gcc/devel/c++-modules] aarch64: Fix up __aarch64_cas16_acq_rel fallback Nathan Sidwell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).