<html>
<head>
<base href="http://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 --- - Missed optimisation for modulo 2"
href="http://llvm.org/bugs/show_bug.cgi?id=21929">21929</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Missed optimisation for modulo 2
</td>
</tr>
<tr>
<th>Product</th>
<td>new-bugs
</td>
</tr>
<tr>
<th>Version</th>
<td>3.4
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Windows NT
</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>nick@indigorenderer.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>See Godbolt snippet here: <a href="http://goo.gl/imHtck">http://goo.gl/imHtck</a>
inline int intMod(int x, int y)
{
const int r = x % y;
if(r < 0)
return y + r;
else
return r;
}
int f(int x)
{
return intMod(x, 2); // Should this optimse to x & 0x1 ?
//return x & 0x1;
}
Compiles to:
f(int): # @f(int)
movl %edi, %eax
shrl $31, %eax
addl %edi, %eax
andl $-2, %eax
subl %eax, %edi
movl %edi, %eax
shrl $31, %eax
leal (%rdi,%rax,2), %eax
ret
It seems to be valid to make the optimisation intMod(x, 2) = x & 0x1,
which LLVM doesn't do.</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>