<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 --- - GVN incorrectly propagates exact attribute" href="https://urldefense.proofpoint.com/v2/url?u=https-3A__llvm.org_bugs_show-5Fbug.cgi-3Fid-3D23922&d=AwMBaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=pF93YEPyB-J_PERP4DUZOJDzFVX5ZQ57vQk33wu0vio&m=S5d-G-pINhhWLLUoC90uNDEX2o08HKaVx0NsNKA7RZ4&s=2haMOyv9V0pXpgPJgJw7Rg-rnykQ_uxjdQEAs5ZVptg&e=">23922</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>GVN incorrectly propagates exact attribute
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>All
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Keywords</th>
<td>miscompilation
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</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>nunoplopes@sapo.pt
</td>
</tr>
<tr>
<th>CC</th>
<td>david.majnemer@gmail.com, llvmbugs@cs.uiuc.edu, regehr@cs.utah.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>$ cat bug.ll
define i2 @func16731728(i2, i1, i4, i2, i1, i4, i2, i1, i4, i2, i1, i4) {
%13 = sdiv exact i2 %0, -2
%14 = sdiv i2 %0, -2
%15 = select i1 %1, i2 %13, i2 %14
ret i2 %15
}
$ opt -gvn -S bug.ll
define i2 @func16731728(i2, i1, i4, i2, i1, i4, i2, i1, i4, i2, i1, i4) {
%13 = sdiv exact i2 %0, -2
ret i2 %13
}
This is wrong if we assume that select only propagates poison/undef through the
dynamically chosen value (which I believe is the current interpretation of how
select works).
$ ./alive.py gvn.opt
----------------------------------------
Optimization: func16731728
Precondition: true
%13 = sdiv exact i2 %0, -2
%14 = sdiv i2 %0, -2
%15 = select i1 %1, i2 %13, i2 %14
=>
%15 = sdiv exact i2 %0, -2
ERROR: Domain of undefinedness of Target is smaller than Source's for i2 %15
Example:
%0 i2 = 0x3 (3, -1)
%1 i1 = 0x0 (0)
%13 i2 = 0x0 (0)
%14 i2 = 0x0 (0)
Source value: 0x0 (0)
Target value: undef</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>