AArch64: Fix __sync_val_compare_and_swap [PR111404]
commitdf8958e6bc5d050dab8bdc5954c1632fb0e98d18
authorWilco Dijkstra <wilco.dijkstra@arm.com>
Thu, 30 Nov 2023 16:14:35 +0000 (30 16:14 +0000)
committerWilco Dijkstra <wilco.dijkstra@arm.com>
Thu, 30 Nov 2023 16:15:29 +0000 (30 16:15 +0000)
tree0cb5e7297e7ba66e3e5653af175c551001f08738
parent18d8a50a042a7faa78626373fdcfe3468c7ae864
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.
gcc/config/aarch64/aarch64.cc
libgcc/config/aarch64/lse.S