This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug rtl-optimization/46235] New: inefficient bittest code generation


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]