<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 - Suboptimal constant propagation for unrolled loop"
href="https://bugs.llvm.org/show_bug.cgi?id=47584">47584</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Suboptimal constant propagation for unrolled loop
</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>david.bolvansky@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>int foo(int p)
{
unsigned i, s = 0;
for (i = 4; i < 20; i++)
{
if (p)
s += i*2; // works for i*3
else
s += i*4;
}
return s;
}
Clang produces:
foo(int): # @foo(int)
cmp edi, 1
mov cl, 1
adc cl, 0
mov eax, 4
shl eax, cl
mov edx, 5
shl edx, cl
mov esi, 6
shl esi, cl
add edx, eax
add esi, edx
mov eax, 7
shl eax, cl
add eax, esi
mov edx, 8
shl edx, cl
mov esi, 9
shl esi, cl
mov edi, 10
shl edi, cl
add edx, eax
add esi, edx
....
But it should just produce:
foo(int): # @foo(int)
test edi, edi
mov ecx, 736
mov eax, 368
cmove eax, ecx
ret</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>