<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 code for range check"
href="https://bugs.llvm.org/show_bug.cgi?id=35557">35557</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>suboptimal code for range check
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</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>LLVM Codegen
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>dvyukov@google.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>clang version 6.0.0 (trunk 320027)
int foobar(int x) {
return x > 16 && x < 32;
}
-O3 produces:
4004d0: 31 c0 xor %eax,%eax
4004d2: 83 ff 11 cmp $0x11,%edi
4004d5: 7c 08 jl 4004df <foobar+0xf>
4004d7: 31 c0 xor %eax,%eax
4004d9: 83 ff 20 cmp $0x20,%edi
4004dc: 0f 9c c0 setl %al
4004df: c3 retq
a more optimal code would be:
400480: 83 ef 11 sub $0x11,%edi
400483: 31 c0 xor %eax,%eax
400485: 83 ff 0e cmp $0xe,%edi
400488: 0f 96 c0 setbe %al
40048b: c3 retq
Besides the sub trick, it's unclear why llvm generates a duplicate "xor
%eax,%eax". That may be a second bug.</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>