[Bug target/25671] New: test_bit() compilation does not expand to "bt" instruction
avi at argo dot co dot il
gcc-bugzilla@gcc.gnu.org
Wed Jan 4 15:24:00 GMT 2006
the code
int test_bit(unsigned long *words, int bit)
{
int wsize = (sizeof *words) * 8;
return (words[bit / wsize] & (1 << (bit % wsize))) != 0;
}
can compile to
xor %rax, %rax
bt %rsi, (%rdi)
setc %al
but instead compiles to a much longer sequence, using many more registers,
which is probably slower as well. If gcc recognized this common idiom (like it
recognizes bit rotate sequences), smaller and more optimal code would be
generated (especially if the result of the test is in an if statement - it
could boil down to a bt; jc sequence).
--
Summary: test_bit() compilation does not expand to "bt"
instruction
Product: gcc
Version: 4.0.2
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: target
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: avi at argo dot co dot il
GCC build triplet: x86_64-redhat-linux
GCC host triplet: x86_64-redhat-linux
GCC target triplet: x86_64-redhat-linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25671
More information about the Gcc-bugs
mailing list