[llvm-bugs] [Bug 38003] New: Fold AND+CMP to CMP
via llvm-bugs
llvm-bugs at lists.llvm.org
Sat Jun 30 06:25:48 PDT 2018
https://bugs.llvm.org/show_bug.cgi?id=38003
Bug ID: 38003
Summary: Fold AND+CMP to CMP
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Scalar Optimizations
Assignee: unassignedbugs at nondot.org
Reporter: david.bolvansky at gmail.com
CC: llvm-bugs at lists.llvm.org
Hello,
bool sw1(int x) {
switch(x) {
case 2:
case 5:
case 6:
case 31:
return true;
default:
return false;
}
}
Clang -03
sw1(int):
add edi, -2 // why?
cmp edi, 29 // fold add + cmp to cmp edi, 31
ja .LBB0_2
mov eax, 536870937
mov ecx, edi
shr eax, cl
and eax, 1
ret
.LBB0_2:
xor eax, eax
ret
GCC 8.1 emits:
sw1(int):
xor eax, eax
cmp edi, 31
ja .L1
mov eax, 1
mov ecx, edi
sal rax, cl
test eax, 2147483752
setne al
.L1:
ret
ICC 18 (more jumps, worse code?):
sw1(int):
cmp edi, 64
jae ..B1.4
mov rax, 0x080000068
bt rax, rdi
jnc ..B1.4
mov eax, 1
ret
..B1.4:
xor eax, eax
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/20180630/d6ec7cb4/attachment.html>
More information about the llvm-bugs
mailing list