public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug target/111404] New: [AArch64] 128-bit __sync_val_compare_and_swap is not atomic @ 2023-09-13 14:45 wilco at gcc dot gnu.org 2023-09-14 17:13 ` [Bug target/111404] " wilco at gcc dot gnu.org 2023-11-30 16:45 ` cvs-commit at gcc dot gnu.org 0 siblings, 2 replies; 3+ messages in thread From: wilco at gcc dot gnu.org @ 2023-09-13 14:45 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111404 Bug ID: 111404 Summary: [AArch64] 128-bit __sync_val_compare_and_swap is not atomic Product: gcc Version: 8.5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: wilco at gcc dot gnu.org Target Milestone: --- This compiles __int128 f(__int128 *p, __int128 *q, __int128 x) { return __sync_val_compare_and_swap (p, *q, x); } into: f: ldp x6, x7, [x1] mov x4, x0 .L3: ldxp x0, x1, [x4] cmp x0, x6 ccmp x1, x7, 0, eq bne .L4 stlxp w5, x2, x3, [x4] cbnz w5, .L3 .L4: dmb ish ret This means if the compare fails, we return the value loaded via LDXP. However unless the STXP succeeds, this returned value is not single-copy atomic. So on failure we still need to execute STLXP. ^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug target/111404] [AArch64] 128-bit __sync_val_compare_and_swap is not atomic 2023-09-13 14:45 [Bug target/111404] New: [AArch64] 128-bit __sync_val_compare_and_swap is not atomic wilco at gcc dot gnu.org @ 2023-09-14 17:13 ` wilco at gcc dot gnu.org 2023-11-30 16:45 ` cvs-commit at gcc dot gnu.org 1 sibling, 0 replies; 3+ messages in thread From: wilco at gcc dot gnu.org @ 2023-09-14 17:13 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111404 Wilco <wilco at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Last reconfirmed| |2023-09-14 Ever confirmed|0 |1 Status|UNCONFIRMED |NEW Target|arm64-*-* |aarch64 --- Comment #1 from Wilco <wilco at gcc dot gnu.org> --- Patch: https://gcc.gnu.org/pipermail/gcc-patches/2023-September/630198.html ^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug target/111404] [AArch64] 128-bit __sync_val_compare_and_swap is not atomic 2023-09-13 14:45 [Bug target/111404] New: [AArch64] 128-bit __sync_val_compare_and_swap is not atomic wilco at gcc dot gnu.org 2023-09-14 17:13 ` [Bug target/111404] " wilco at gcc dot gnu.org @ 2023-11-30 16:45 ` cvs-commit at gcc dot gnu.org 1 sibling, 0 replies; 3+ messages in thread From: cvs-commit at gcc dot gnu.org @ 2023-11-30 16:45 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111404 --- Comment #2 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Wilco Dijkstra <wilco@gcc.gnu.org>: https://gcc.gnu.org/g:df8958e6bc5d050dab8bdc5954c1632fb0e98d18 commit r14-6021-gdf8958e6bc5d050dab8bdc5954c1632fb0e98d18 Author: Wilco Dijkstra <wilco.dijkstra@arm.com> Date: Thu Nov 30 16:14:35 2023 +0000 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. ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-11-30 16:45 UTC | newest] Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2023-09-13 14:45 [Bug target/111404] New: [AArch64] 128-bit __sync_val_compare_and_swap is not atomic wilco at gcc dot gnu.org 2023-09-14 17:13 ` [Bug target/111404] " wilco at gcc dot gnu.org 2023-11-30 16:45 ` cvs-commit at gcc dot gnu.org
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).