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/17236] New: inefficient code for long long multiply on x86


Compiling:
unsigned long long LLM(unsigned long long arg1, unsigned long long arg2)
{
  return arg1 *  arg2;
}

with gcc -O2 -fomit-frame-pointer generates:

        pushl   %ebp
        pushl   %edi
        pushl   %ebx
        pushl   %edi
        pushl   %edi
        movl    32(%esp), %ecx
        movl    24(%esp), %eax
        movl    36(%esp), %ebx
        movl    24(%esp), %edi
        mull    %ecx
        imull   28(%esp), %ecx
        imull   %ebx, %edi
        movl    %edx, %ebp
        movl    %eax, (%esp)
        addl    %edi, %ebp
        movl    (%esp), %eax
        leal    (%ebp,%ecx), %ecx
        movl    %ecx, 4(%esp)
        movl    4(%esp), %edx
        popl    %ecx
        popl    %ebx
        popl    %ebx
        popl    %edi
        popl    %ebp
        ret

ICC -O2 generates much smaller code:

        movl      8(%esp), %ecx                                 #516.18
        imull     12(%esp), %ecx                                #516.18
        movl      16(%esp), %eax                                #516.18
        imull     4(%esp), %eax                                 #516.18
        addl      %eax, %ecx                                    #516.18
        movl      4(%esp), %eax                                 #516.18
        mull      12(%esp)                                      #516.18
        addl      %ecx, %edx                                    #516.18
        ret                                                     #516.18

-- 
           Summary: inefficient code for long long multiply on x86
           Product: gcc
           Version: 3.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: rtl-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: dann at godzilla dot ics dot uci dot edu
                CC: gcc-bugs at gcc dot gnu dot org


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


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