<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 --- - Incorrect results from atomic builtins"
href="https://llvm.org/bugs/show_bug.cgi?id=22923">22923</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Incorrect results from atomic builtins
</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>Linux
</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: PowerPC
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>nemanja.i.ibm@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>This test case is just an instance of the issue. It would appear that the code
for part-word atomic instructions is incorrect (pwr6 and older CPUs). The
availability of the part-word larx/stcx. seems to do away with the problem.
Test case (running on a Power8 LE host):
#include <stdio.h>
signed char sc = 'a';
unsigned char uc = 'b';
int main(void)
{
__sync_val_compare_and_swap(&sc, 'b', 'c');
__sync_val_compare_and_swap(&uc, 'b', 'c');
printf("sc = %c\n", sc);
printf("uc = %c\n", uc);
}
$ clang --version
clang version 3.7.0 (trunk 231831) (llvm/trunk 231828:231843M)
$ clang atomic_bug.c -mcpu=pwr6
$ ./a.out
sc = a
uc = b
$ gcc --version
gcc (Ubuntu 4.8.2-19ubuntu1) 4.8.2
$ gcc atomic_bug.c -mcpu=power6
$ ./a.out
sc = a
uc = c</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>