This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug rtl-optimization/46235] New: inefficient bittest code generation
- From: "davidxl at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 30 Oct 2010 00:17:28 +0000
- Subject: [Bug rtl-optimization/46235] New: inefficient bittest code generation
- Auto-submitted: auto-generated
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: unassigned@gcc.gnu.org
ReportedBy: davidxl@gcc.gnu.org
CC: xinliangli@gmail.com
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