This is the mail archive of the 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]

optimization/6585: useless memory store instructions on x86

>Number:         6585
>Category:       optimization
>Synopsis:       useless memory store instructions on x86
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    unassigned
>State:          open
>Class:          pessimizes-code
>Submitter-Id:   net
>Arrival-Date:   Mon May 06 13:06:00 PDT 2002
>Originator:     Bruno Haible
>Release:        3.1 20020423 (prerelease)
GNU hackers
System: Linux linuix 2.4.18-4GB #1 Wed Mar 27 13:57:05 UTC 2002 i686 unknown
Architecture: i686

host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ../configure --prefix=/packages/gnu-snapshot --enable-shared --enable-version-specific-runtime-libs --enable-nls

A case of a useless memory store and of a useless register spill.

=========================== mul.c ===============================
long long mul (long long a, long long b) {
  return a * b;

$ gcc -v
Lecture des spécification à partir de /packages/gnu-snapshot/lib/gcc-lib/i686-pc-linux-gnu/3.1/specs
Configuré avec: ../configure --prefix=/packages/gnu-snapshot --enable-shared --enable-version-specific-runtime-libs --enable-nls
Modèle de thread: single
version gcc 3.1 20020423 (prerelease)

$ gcc -O6 -fomit-frame-pointer -S mul.c
$ cat mul.s
        .file   "mul.c"
        .align 2
        .p2align 4,,15
.globl mul
        .type   mul,@function
        subl    $28, %esp
        movl    40(%esp), %ecx      b0
        movl    %ebx, 12(%esp)                        save %ebx
        movl    32(%esp), %ebx      a0
        movl    %ebp, 24(%esp)                        save %ebp
        movl    44(%esp), %ebp      b1
        movl    %ebx, %eax          a0
        mull    %ecx                %edx:%eax := a0*b0
        movl    %edi, 20(%esp)                        save %edi
        movl    36(%esp), %edi      a1
        movl    %esi, 16(%esp)                        save %esi USELESS!
        movl    16(%esp), %esi                        restore %esi USELESS!
        imull   %edi, %ecx          a1*b0
        movl    %eax, (%esp)
        movl    20(%esp), %edi                        restore %edi
        movl    %ebx, %eax          a0
        movl    %edx, 4(%esp)                         USELESS!
        imull   %ebp, %eax          a0*b1
        movl    12(%esp), %ebx                        restore %ebx
        movl    24(%esp), %ebp                        restore %ebp
        addl    %eax, %edx          hi+a0*b1
        movl    (%esp), %eax        lo
        movl    %edx, 4(%esp)       hi+a0*b1          ! Could be simplified
        addl    %ecx, 4(%esp)       hi+a0*b1+a1*b0    ! to a single insn:
        movl    4(%esp), %edx                         ! addl %ecx, $edx
        addl    $28, %esp
        .size   mul,.Lfe1-mul
        .ident  "GCC: (GNU) 3.1 20020423 (prerelease)"


gcc -O6 -fomit-frame-pointer -S mul.c


more optimizations

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