<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 - GVN should leave loads alone that feed only into assumes"
href="https://bugs.llvm.org/show_bug.cgi?id=49980">49980</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>GVN should leave loads alone that feed only into assumes
</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>Scalar Optimizations
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>jdoerfert@anl.gov
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>As part of the new OpenMP device runtime we transform assertions into
`__builtin_assume` in release mode. This works just fine except that the GVN
pass, despite all load-pre options set to disable, messes with the code in ways
that are unfortunate.
I haven't distilled a perfect example but the following code gives an idea (
<a href="https://godbolt.org/z/8z719n6We">https://godbolt.org/z/8z719n6We</a>):
```
int G;
int foo(int);
void square(int num, int *__restrict__ A) {
for (int i = 0; i < 100; ++i) {
__builtin_assume(G == 42);
if (A[i])
A[i] = foo(i);
__builtin_assume(G == 42);
}
}
```
What I want is the load that feeds into the assume to just stay with the
assume, make it simple to leverage the condition later on.
What happens is that the load is hoisted, sunk, deduplicated, etc., all is not
helpful, in parts because we will drop those loads in the end anyway.
I assume GVN needs to be aware of the result of
`CodeMetrics::collectEphemeralValues` to avoid "optimizing" things we will drop
anyway.</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>