https://bugs.llvm.org/show_bug.cgi?id=51102
Bug ID: 51102
Summary: [AArch64] Wrong code generated (?) for
compare_exchange_strong on __int128_t
Product: libraries
Version: trunk
Hardware: PC
OS: Windows NT
Status: NEW
Severity: enhancement
Priority: P
Component: Backend: AArch64
Assignee: unassignedb...@nondot.org
Reporter: efrie...@quicinc.com
CC: arnaud.degrandmai...@arm.com,
llvm-bugs@lists.llvm.org, smithp...@googlemail.com,
ties.st...@arm.com
Consider:
#include <stdatomic.h>
__int128_t ff(_Atomic __int128_t *p) {
__int128_t e = 0;
atomic_compare_exchange_strong(p, &e, 0);
return e;
}
ff:
mov x8, x0
.LBB0_1:
ldaxp x0, x1, [x8]
orr x9, x0, x1
cbnz x9, .LBB0_4
stlxp w9, xzr, xzr, [x8]
cbnz w9, .LBB0_1
ret
.LBB0_4:
clrex
ret
This sequence is subtly wrong in the case where the cmpxchg fails.
Specifically, the ldaxp is not single-copy atomic, so the returned value might
tear. At least, that's my understanding of the rules here. So we need to
replace the "clrex" with a sequence like "stlxp w9, x0, x1, [x8]; cbnz w9,
.LBB0_1".
Not sure if this sort of tearing can actually happen in practice on commonly
used AArch64 chips.
I'll throw together a patch.
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs