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]

More linpack on i386-linux analysis


I've been looking at the inner loop of daxpy() in linpack
for i386-linux:

Here's the code generated by gcc-2.7.2; the loop counter is
nicely allocated in a register:

1051:linpackc.c    ****                         dy[iy] = dy[iy] + da*dx[ix];
 2801                   .LM356:
 2802 1724 D9C0                 fld %st(0)
 2803 1726 8B7510               movl 16(%ebp),%esi
 2804 1729 D80C8E               fmuls (%esi,%ecx,4)
 2805 172c D800                 fadds (%eax)
 2806 172e D918                 fstps (%eax)
1052:linpackc.c    ****                         ix = ix + incx;
 2808                   .LM357:
 2809 1730 034D14               addl 20(%ebp),%ecx
1053:linpackc.c    ****                         iy = iy + incy;
 2811                   .LM358:
 2812 1733 8B7D1C               movl 28(%ebp),%edi
 2813 1736 8D04B8               leal (%eax,%edi,4),%eax
 2815                   .LM359:
 2816 1739 42                   incl %edx               <- here
 2817 173a 39DA                 cmpl %ebx,%edx          <- here
 2818 173c 7CE6                 jl .L224

Here's the code generated by egcs-19980707: the loop counter
is allocated to a stack slot:

1051:/home/tm/linpackc.c ****                   dy[iy] = dy[iy] + da*dx[ix];
 3064                   .LM395:
 3065 1820 8B7D10               movl 16(%ebp),%edi
 3066 1823 D9C0                 fld %st(0)
 3067 1825 D80C8F               fmuls (%edi,%ecx,4)
 3068 1828 D80493               fadds (%ebx,%edx,4)
 3070                   .LM396:
 3071 182b FF45FC               incl -4(%ebp)
1052:/home/tm/linpackc.c ****                   ix = ix + incx;
 3073                   .LM397:
 3074 182e 034D14               addl 20(%ebp),%ecx
 3076                   .LM398:
 3077 1831 D91C93               fstps (%ebx,%edx,4)
1053:/home/tm/linpackc.c ****                   iy = iy + incy;
 3079                   .LM399:
 3080 1834 03551C               addl 28(%ebp),%edx      <- here
 3082                   .LM400:
 3083 1837 3975FC               cmpl %esi,-4(%ebp)      <- here
 3084 183a 7CE4                 jl .L226

The egcs version of the loop requires three more memory accesses
(incl is read/write + cmpl is read).

The "incl mem" is especially unfortunate because the Pentium is a
dual-issue lock-step pipeline architecture; it requires
three clocks to execute "incl mem" during which the other pipe 
is stalled. Both "incl mem" and "decl mem" are highly deprecated
by Intel for the Pentium. *1

In addition, the "incl mem" translates into four micro-ops on
the Pentium Pro, which is one more micro-op than separate
instructions. *2

It would probably be advantageous to highly deprecate the usage
of the "incl mem" and "decl mem" instructions.

Also, if someone could investigate why the loop counter is not
allocated to a register by egcs that would be even better.

Toshi

*1 "Optimizing Applications for the Pentium(R) Processor,
   "Improving Pairing" section, Intel Architecture Labs

*2 "Intel Architecture Optimization Manual",
    page 2-6, Intel Architecture Labs



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