aboutsummaryrefslogtreecommitdiff
path: root/libgcc
diff options
context:
space:
mode:
authorWilco Dijkstra <wilco.dijkstra@arm.com>2023-11-30 16:14:35 +0000
committerWilco Dijkstra <wilco.dijkstra@arm.com>2023-11-30 16:15:29 +0000
commitdf8958e6bc5d050dab8bdc5954c1632fb0e98d18 (patch)
tree0cb5e7297e7ba66e3e5653af175c551001f08738 /libgcc
parent18d8a50a042a7faa78626373fdcfe3468c7ae864 (diff)
downloadgcc-df8958e6bc5d050dab8bdc5954c1632fb0e98d18.zip
gcc-df8958e6bc5d050dab8bdc5954c1632fb0e98d18.tar.gz
gcc-df8958e6bc5d050dab8bdc5954c1632fb0e98d18.tar.bz2
AArch64: Fix __sync_val_compare_and_swap [PR111404]
__sync_val_compare_and_swap may be used on 128-bit types and either calls the outline atomic code or uses an inline loop. On AArch64 LDXP is only atomic if the value is stored successfully using STXP, but the current implementations do not perform the store if the comparison fails. In this case the value returned is not read atomically. gcc/ChangeLog: PR target/111404 * config/aarch64/aarch64.cc (aarch64_split_compare_and_swap): For 128-bit store the loaded value and loop if needed. libgcc/ChangeLog: PR target/111404 * config/aarch64/lse.S (__aarch64_cas16_acq_rel): Execute STLXP using either new value or loaded value.
Diffstat (limited to 'libgcc')
-rw-r--r--libgcc/config/aarch64/lse.S11
1 files changed, 7 insertions, 4 deletions
diff --git a/libgcc/config/aarch64/lse.S b/libgcc/config/aarch64/lse.S
index f64a3e9..046dd40 100644
--- a/libgcc/config/aarch64/lse.S
+++ b/libgcc/config/aarch64/lse.S
@@ -163,6 +163,8 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#define tmp0 16
#define tmp1 17
#define tmp2 15
+#define tmp3 14
+#define tmp4 13
/* Start and end a function. */
.macro STARTFN name
@@ -233,10 +235,11 @@ STARTFN NAME(cas)
0: LDXP x0, x1, [x4]
cmp x0, x(tmp0)
ccmp x1, x(tmp1), #0, eq
- bne 1f
- STXP w(tmp2), x2, x3, [x4]
- cbnz w(tmp2), 0b
-1: BARRIER
+ csel x(tmp2), x2, x0, eq
+ csel x(tmp3), x3, x1, eq
+ STXP w(tmp4), x(tmp2), x(tmp3), [x4]
+ cbnz w(tmp4), 0b
+ BARRIER
ret
#endif