[llvm-bugs] [Bug 39116] New: Better switch lowering using and + sete
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Sep 28 11:17:05 PDT 2018
https://bugs.llvm.org/show_bug.cgi?id=39116
Bug ID: 39116
Summary: Better switch lowering using and + sete
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Backend: X86
Assignee: unassignedbugs at nondot.org
Reporter: david.bolvansky at gmail.com
CC: llvm-bugs at lists.llvm.org
bool switch_ob_one_two_cases(int x) {
switch(x) {
case 0:
case 2:
return true;
default:
return false;
}
}
Clang:
switch_ob_one_two_cases(int):
mov al, 1
or edi, 2
cmp edi, 2
jne .LBB0_1
ret
.LBB0_1:
xor eax, eax
ret
GCC can emit nice code:
switch_ob_one_two_cases(int):
and edi, -3
sete al
ret
bool switch_ob_one_two_cases2(int x) {
switch(x) {
case 7:
case 11:
return true;
default:
return false;
}
}
GCC:
switch_ob_one_two_cases2(int):
sub edi, 7
and edi, -5
sete al
ret
--
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/20180928/235d1a02/attachment.html>
More information about the llvm-bugs
mailing list