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/16541] code quality issue for bit manipulations with 64bit


------- Additional Comments From dann at godzilla dot ics dot uci dot edu  2004-07-14 21:58 -------
Here is a simplified test case that shows a code quality regression:

extern unsigned char first_one[65536];
int FirstOnet(unsigned long long arg1)
{
  if (arg1 >> 48)
    return (first_one[arg1 >> 48]);
  return 0;
}

the code generated by gcc-3.0 -O2 -fomit-frame-pointer is:

        movl    8(%esp), %edx
        movl    %edx, %eax
        shrl    $16, %eax
        xorl    %edx, %edx
        movl    %eax, %ecx
        orl     %edx, %ecx
        je      .L3
        movzbl  first_one(%eax), %eax
        ret
        .p2align 2
.L3:
        xorl    %eax, %eax
        ret

and by mainline (a bit worse): 

        pushl   %ebx               <- using a callee saved register
        xorl    %ecx, %ecx
        movl    12(%esp), %edx
        movl    %edx, %eax         <- why not load directly to eax?
        xorl    %edx, %edx
        shrl    $16, %eax
        movl    %edx, %ebx
        orl     %eax, %ebx
        je      .L4
        movzbl  first_one(%eax), %ecx
.L4:
        popl    %ebx
        movl    %ecx, %eax
        ret


Here is what Intel's compiler generates:

        movzwl    10(%esp), %edx                                #28.5
        xorl      %eax, %eax                                    #30.3
        orl       %edx, %eax                                    #30.3
        je        ..B1.3        # Prob 50%                      #30.3
                                # LOE edx ebx ebp esi edi
..B1.2:                         # Preds ..B1.1
        movzbl    first_one(%edx), %eax                         #31.13
        ret                                                     #31.13
                                # LOE
..B1.3:                         # Preds ..B1.1
        xorl      %eax, %eax                                    #32.10
        ret                                                     #32.10




-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16541


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