<html>
<head>
<base href="http://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 - Extra broadcasts in doubly-unrolled avx2 memcpy loop"
href="http://bugs.llvm.org/show_bug.cgi?id=32085">32085</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Extra broadcasts in doubly-unrolled avx2 memcpy loop
</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>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Backend: X86
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>justin.lebar@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>At clang head
$ echo '#include <cstring>
void* go5(int val) {
int* arr = new int[8 * 128];
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 128; j++) {
memcpy(&arr[i * 128 + j], &val, sizeof(int));
}
}
return arr;
}' | clang++ -O2 -x c++ -g0 --std=c++11 -mavx2 - -o - -S -mllvm
--x86-asm-syntax=intel
Output: <a href="https://gist.github.com/da5e8e50ba43cf1600ac652b35fd6746">https://gist.github.com/da5e8e50ba43cf1600ac652b35fd6746</a>
LLVM unrolls both loops, but at the beginning of each iteration of the outer
loop, we re-broadcast into our ymm register.
vmovd xmm0, ebx
vbroadcastss ymm0, xmm0
vmovups ymmword ptr [rax], ymm0
vmovups ymmword ptr [rax + 32], ymm0
[...]
vmovd xmm0, ebx
vbroadcastss ymm0, xmm0
vmovups ymmword ptr [rax + 512], ymm0
vmovups ymmword ptr [rax + 544], ymm0
[...]
We shouldn't need to do this.</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>