[llvm-bugs] [Bug 49552] New: switch over select is not optimized
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Mar 11 17:14:33 PST 2021
https://bugs.llvm.org/show_bug.cgi?id=49552
Bug ID: 49552
Summary: switch over select is not optimized
Product: libraries
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: Backend: X86
Assignee: unassignedbugs at nondot.org
Reporter: nok.raven at gmail.com
CC: craig.topper at gmail.com, llvm-bugs at lists.llvm.org,
llvm-dev at redking.me.uk, pengfei.wang at intel.com,
spatel+llvm at rotateright.com
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
---
https://godbolt.org/z/e9vjYK
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210312/2ad7c56a/attachment.html>
More information about the llvm-bugs
mailing list