<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 - LLVM does not see that two writes are independent."
href="https://bugs.llvm.org/show_bug.cgi?id=46319">46319</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>LLVM does not see that two writes are independent.
</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>All
</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>LLVM Codegen
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>denis.yaroshevskij@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>See this part of a simd optimized routine that doubles every element in an
array.
<a href="https://godbolt.org/z/SLp3Ec">https://godbolt.org/z/SLp3Ec</a>
Even though clang can in both cases successfully see that all 4 reads are
independent:
```
vmovdqa ymm0, ymmword ptr [rdi]
vmovdqa ymm1, ymmword ptr [rdi + 32]
vmovdqa ymm2, ymmword ptr [rdi + 64]
vmovdqa ymm3, ymmword ptr [rdi + 96]
```
It introduces dependencies between independent computations by default:
```
vpaddd ymm0, ymm0, ymm0
vmovdqa ymmword ptr [rdi], ymm0
vpaddd ymm0, ymm1, ymm1
vmovdqa ymmword ptr [rdi + 32], ymm0
...
```
While I suspect it should be just `loads, adds, stores`
This is also what clang generates when auto-vectorizing this:
<a href="https://godbolt.org/z/ik55Yv">https://godbolt.org/z/ik55Yv</a>
NOTE: on my measurements hacking around this didn't have an effect, probably
the processor could figure it out on it's own. However, this is not ideal and I
can imagine you can encounter a situation when this will backfire.</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>