<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 - switch over select is not optimized"
href="https://bugs.llvm.org/show_bug.cgi?id=49552">49552</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>switch over select is not optimized
</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>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Backend: X86
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>nok.raven@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>craig.topper@gmail.com, llvm-bugs@lists.llvm.org, llvm-dev@redking.me.uk, pengfei.wang@intel.com, spatel+llvm@rotateright.com
</td>
</tr></table>
<p>
<div>
<pre>inline int test(char a, char b)
{
#ifndef NO_SELECT
return a < b ? -1 : a > b ? 1 : 0;
#else
if (a < b) return -1;
if (a > b) return 1;
return 0;
#endif
}
void fl();
void fe();
void fg();
void foo(char a, char b)
{
switch (test(a, b)) {
case -1: return fl();
case 0: return fe();
case 1: return fg();
}
}
---
; -DNO_SELECT
foo(char, char):
cmp dil, sil
jge .LBB0_1
jmp fl()
.LBB0_1:
jle .LBB0_4
jmp fg()
.LBB0_4:
jmp fe()
;
foo(char, char):
xor ecx, ecx
cmp dil, sil
setg cl
mov eax, -1
cmovge eax, ecx
cmp eax, 1
je .LBB0_5
test eax, eax
je .LBB0_4
cmp eax, -1
jne .LBB0_6
jmp fl()
.LBB0_5:
jmp fg()
.LBB0_4:
jmp fe()
.LBB0_6:
ret
---
<a href="https://godbolt.org/z/e9vjYK">https://godbolt.org/z/e9vjYK</a></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>