<html>
<head>
<base href="https://bugs.llvm.org/">
</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 - Poor codegen with atomics"
href="https://bugs.llvm.org/show_bug.cgi?id=37716">37716</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Poor codegen with atomics
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</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>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>C++
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>redbeard0531@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>dgregor@apple.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre><a href="https://godbolt.org/g/QcLkce">https://godbolt.org/g/QcLkce</a>
#include <atomic>
std::atomic<int> progress{-1};
void combine_writes1() {
// These should be reduced to a single store(0,release),
// At least as long as release-sequence includes same-thread
// relaxed stores. If that is removed, this should just be
// a single relaxed store.
progress.store(0, std::memory_order_relaxed);
progress.store(0, std::memory_order_relaxed);
progress.store(0, std::memory_order_release);
progress.store(0, std::memory_order_release);
progress.store(0, std::memory_order_relaxed);
progress.store(0, std::memory_order_relaxed);
}
void combine_writes2() {
// Ditto above, but should store 5.
progress.store(0, std::memory_order_relaxed);
progress.store(1, std::memory_order_relaxed);
progress.store(2, std::memory_order_release);
progress.store(3, std::memory_order_release);
progress.store(4, std::memory_order_relaxed);
progress.store(5, std::memory_order_relaxed);
}
void combine_loads() {
// These should be reduced to either a single acquire-load
// or an acquire fence.
progress.load(std::memory_order_relaxed);
progress.load(std::memory_order_relaxed);
progress.load(std::memory_order_acquire);
progress.load(std::memory_order_acquire);
progress.load(std::memory_order_relaxed);
progress.load(std::memory_order_relaxed);
}
combine_writes1(): # @combine_writes1()
mov dword ptr [rip + progress], 0
mov dword ptr [rip + progress], 0
mov dword ptr [rip + progress], 0
mov dword ptr [rip + progress], 0
mov dword ptr [rip + progress], 0
mov dword ptr [rip + progress], 0
ret
combine_writes2(): # @combine_writes2()
mov dword ptr [rip + progress], 0
mov dword ptr [rip + progress], 1
mov dword ptr [rip + progress], 2
mov dword ptr [rip + progress], 3
mov dword ptr [rip + progress], 4
mov dword ptr [rip + progress], 5
ret
combine_loads(): # @combine_loads()
mov eax, dword ptr [rip + progress]
mov eax, dword ptr [rip + progress]
mov eax, dword ptr [rip + progress]
mov eax, dword ptr [rip + progress]
mov eax, dword ptr [rip + progress]
mov eax, dword ptr [rip + progress]
ret
progress:
.long 4294967295 # 0xffffffff
Possibly related to <a class="bz_bug_link
bz_status_NEW "
title="NEW - Codegen can result in multiple sequential mfence instructions"
href="show_bug.cgi?id=37690">https://bugs.llvm.org/show_bug.cgi?id=37690</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>