<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 --- - Indvars not respecting "nuw" property on add, leading to infinite loop"
href="https://llvm.org/bugs/show_bug.cgi?id=30629">30629</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Indvars not respecting "nuw" property on add, leading to infinite loop
</td>
</tr>
<tr>
<th>Product</th>
<td>new-bugs
</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>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>new bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>mikael.holmen@ericsson.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=17414" name="attach_17414" title="Reproducer">attachment 17414</a> <a href="attachment.cgi?id=17414&action=edit" title="Reproducer">[details]</a></span>
Reproducer
It seems like indvars can produce wrong output.
In the input we have the following loop counter update and test
%_tmp4 = icmp ult i16 %uc.1.0, 65535
%_tmp2 = add nuw i16 %uc.1.0, 1
indvars rewrites this to
%_tmp2 = add nuw i16 %uc.1.0, 1
%exitcond = icmp ne i16 %_tmp2, 0
Note that the input add instruction was "nuw", and the "nuw" property is still
left on the add after the transformation, but now the add will indeed
overflow!
If running e.g. instcombine afterwards the icmp is simply replaced with i1 true
and we get an infinite loop.
Reproduce with:
opt -S ./indvar-bug.ll -indvars</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>