http://llvm.org/bugs/show_bug.cgi?id=14365
Bug #: 14365
Summary: Missed optimization for a simple bit twiddling
Product: libraries
Version: trunk
Platform: PC
OS/Version: FreeBSD
Status: NEW
Severity: enhancement
Priority: P
Component: Common Code Generator Code
AssignedTo: [email protected]
ReportedBy: [email protected]
CC: [email protected]
Classification: Unclassified
I've been bit twiddling lately and found this:
% cat test.c
int test(int a) { return (a + (~(a & 0x55555555) + 1)); }
% clang -O2 -c test.c
% objdump -d test.o
test.o: file format elf64-x86-64-freebsd
Disassembly of section .text:
0000000000000000 <test>:
0: 89 f8 mov %edi,%eax
2: 0d aa aa aa aa or $0xaaaaaaaa,%eax
7: 35 55 55 55 55 xor $0x55555555,%eax
c: 8d 44 07 01 lea 0x1(%rdi,%rax,1),%eax
10: c3 retq
FYI, GCC nicely folded it into just one instruction:
% gcc48 -O2 -c test.c
% objdump -d test.o
test.o: file format elf64-x86-64-freebsd
Disassembly of section .text:
0000000000000000 <test>:
0: 89 f8 mov %edi,%eax
2: 25 aa aa aa aa and $0xaaaaaaaa,%eax
7: c3 retq
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs