[llvm-bugs] [Bug 30531] New: Large lookup table could be packed into 64-bit integer
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Sep 26 14:38:17 PDT 2016
https://llvm.org/bugs/show_bug.cgi?id=30531
Bug ID: 30531
Summary: Large lookup table could be packed into 64-bit integer
Product: new-bugs
Version: 3.8
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: new bugs
Assignee: unassignedbugs at nondot.org
Reporter: skvadrik at gmail.com
CC: llvm-bugs at lists.llvm.org
Classification: Unclassified
Consider the following source code (1.c):
int f(char c)
{
switch (c) {
case 'A'...'Z':
case 'a'...'z':
return 1;
default:
return 0;
}
}
$ clang-3.8 -O2 -c 1.c -o 1.o && objdump -dr 1.o`
0000000000000000 <f>:
0: 83 c7 bf add $0xffffffbf,%edi
3: 83 ff 39 cmp $0x39,%edi
6: 77 0b ja 13 <f+0x13>
8: 48 63 c7 movslq %edi,%rax
b: 8b 04 85 00 00 00 00 mov 0x0(,%rax,4),%eax
e: R_X86_64_32S .rodata
12: c3 retq
13: 31 c0 xor %eax,%eax
15: c3 retq
Clang generates 232-byte lookup table in .rodata. For comparison, gcc packs
lookup table in one 64-bit integer:
$ gcc-5.4.0 -O2 -c 1.c -o 1.o && objdump -dr 1.o`
0000000000000000 <f>:
0: 8d 4f bf lea -0x41(%rdi),%ecx
3: 31 c0 xor %eax,%eax
5: 80 f9 39 cmp $0x39,%cl
8: 77 18 ja 22 <f+0x22>
a: b8 01 00 00 00 mov $0x1,%eax
f: 48 ba ff ff ff 03 ff movabs $0x3ffffff03ffffff,%rdx
16: ff ff 03
19: 48 d3 e0 shl %cl,%rax
1c: 48 85 d0 test %rdx,%rax
1f: 0f 95 c0 setne %al
22: 0f b6 c0 movzbl %al,%eax
25: c3 retq
--
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/20160926/849e78fb/attachment-0001.html>
More information about the llvm-bugs
mailing list