<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 - Miscompilation in middle-end (pointer arithmetic and comparisons)"
href="https://bugs.llvm.org/show_bug.cgi?id=49662">49662</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Miscompilation in middle-end (pointer arithmetic and comparisons)
</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>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>maltsevm@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=24663" name="attach_24663" title="Reproducer as C source code">attachment 24663</a> <a href="attachment.cgi?id=24663&action=edit" title="Reproducer as C source code">[details]</a></span>
Reproducer as C source code
The attached source code is miscompiled with trunk build of Clang:
$ clang -O2 test.c -o test && ./test
failed: distance(i, j) >= 2
(the expected output is "passed")
Git bisect points to the following commit:
<a href="https://github.com/llvm/llvm-project/commit/2ad1f5eb1a47275593bd9baf75dcf3e9c3977473">https://github.com/llvm/llvm-project/commit/2ad1f5eb1a47275593bd9baf75dcf3e9c3977473</a>
(although it might not be the root cause)
I tried to reduce the test case in such a way that LLVM IR still looked
reasonable to me and got the following result:
$ lli test-reduced.ll
passed
$ opt -indvars -inline -instcombine -jump-threading test-reduced.ll -o test.bc
$ lli test.bc
failed: distance(i, j) >= 2</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>