<html>
<head>
<base href="https://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - [AArch64] cmpxchg produces inverted success flag at -O0"
href="https://llvm.org/bugs/show_bug.cgi?id=28819">28819</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[AArch64] cmpxchg produces inverted success flag at -O0
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Windows NT
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Backend: AArch64
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>gberry@codeaurora.org
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>The success status flag generated for cmpxchg instructions is inverted when
compiled at -O0. cmpxchg is supposed to return 1 for success, but looking at
the generated code for llvm/test/CodeGen/AArch64/cmpxchg-O0.ll:test_cmpxchg_64:
test_cmpxchg_64: // @test_cmpxchg_64
// BB#0:
sub sp, sp, #16 // =16
.LBB3_1: // =>This Inner Loop Header: Depth=1
ldaxr x8, [x0]
cmp x8, x1
b.ne .LBB3_3
// BB#2: // in Loop: Header=BB3_1 Depth=1
stlxr w9, x2, [x0]
cbnz w9, .LBB3_1
.LBB3_3:
subs x0, x8, x1
cset w1, eq
str x0, [sp, #8] // 8-byte Folded Spill
mov x0, x8
str w9, [sp, #4] // 4-byte Folded Spill
add sp, sp, #16 // =16
ret
The success flag (w9) will always be 0 (or the loop won't terminate).
This only occurs at -O0, and I believe was introduced by the fix for
<a class="bz_bug_link
bz_status_RESOLVED bz_closed"
title="RESOLVED FIXED - AArch64 atomic operations disrupted by fast-regalloc"
href="show_bug.cgi?id=25526">https://llvm.org/bugs/show_bug.cgi?id=25526</a></pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>