<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 --- - Loop not optimized away"
href="https://llvm.org/bugs/show_bug.cgi?id=28969">28969</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Loop not optimized away
</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>All
</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>Loop Optimizer
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>jmuizelaar@mozilla.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>Compiling this code with clang with -Oz gives
void m();
void l(unsigned int r) {
for (unsigned int x = 0, q = 0; x<r; x++, q++) {
if (q == r) {
m();
}
}
}
(__TEXT,__text) section
_l:
pushq %rbp
movq %rsp, %rbp
leal 0x1(%rdi), %eax
xorl %ecx, %ecx
movl %eax, %edx
andl $0x7, %edx
je 0x18
xorl %ecx, %ecx
incl %ecx
cmpl %ecx, %edx
jne 0x12
cmpl $0x7, %edi
jb 0x24
subl %ecx, %eax
addl $-0x8, %eax
jne 0x1f
popq %rbp
retq
changing:
if (q == r) {
to:
if (x == r) {
allows clang to successfully optimize the function away.
gcc optimizes the function away without any changes.</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>