http://llvm.org/bugs/show_bug.cgi?id=20971
Bug ID: 20971
Summary: performance: deduce least significant bits of a
pointer from alignment
Product: new-bugs
Version: unspecified
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: new bugs
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected]
Classification: Unclassified
Here is a small performance opportunity:
struct S {
long x; // 8-aligned
int a, b;
};
unsigned long a_bits(S *s) {
return reinterpret_cast<unsigned long>(&s->a) & 7;
}
unsigned long b_bits(S *s) {
return reinterpret_cast<unsigned long>(&s->b) & 7;
}
s->a is known to be 0 mod 8, and s->b to be 4 mod 8.
Gcc uses it to optimize the code:
a_bits:
xorl %eax, %eax
ret
b_bits:
movl $4, %eax
ret
Clang does not:
a_bits:
leal 8(%rdi), %eax
andq $7, %rax
retq
b_bits:
leal 12(%rdi), %eax
andq $7, %rax
retq
Such optimization applied after ASAN instrumentation will reduce asan overhead,
see https://www.mail-archive.com/[email protected]/msg88631.html
It's probably better to implement it as a separate thing than trying to
make this optimization specifically in asan.
Thoughts?
--
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