http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46235
Summary: inefficient bittest code generation
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: normal
Priority: P3
Component: rtl-optimization
AssignedTo: [email protected]
ReportedBy: [email protected]
CC: [email protected]
Test case:
int foo(int a, int x, int y)
{
if (a & (1 << x))
return a;
return 1;
}
Trunk gcc generates:
foo:
.LFB0:
.cfi_startproc
movl %edi, %eax
movl %edi, %edx
movl %esi, %ecx
sarl %cl, %edx
andl $1, %edx
movl $1, %edx
cmove %edx, %eax
ret
Trunk llvm (with clang) generates:
foo:
.Leh_func_begin0:
btl %esi, %edi
movl $1, %eax
cmovbl %edi, %eax
ret