No optimization works on Alpha?

Oskar Enoksson osken393@student.liu.se
Mon Sep 28 17:39:00 GMT 1998


I recently wrote about the non-working loop unrolling on egcs for Alpha
and got a patch that fixed it by Jim Wilson (Thanks!)

Now I'm beginning to suspect that there are other important non-working
optimization features. The following code is painfully slow on my OSF4.0
ev56 Alpha using egcs-980921:

/* Begin foo.cc */

#define Op(a,i,j,k) a[(k*50+j)*50+i]

main() {
  float a[50*50*50];
  int i,j,k;

  for(k=0; k<50; k++)
    for(j=0; j<50; j++)
      for(i=0; i<50; i++)
        Op(a,i,j,k)=Op(a,i,j,k)*Op(a,i,j,k);
}

/* end foo.cc */

The common integer subexpressions above do not seem to get elimintated,
nor are they moved outside the loop as can be seen from the assembler
further down. (At least, this is what I think, but I must admit I don't
know enough Alpha assembler to actually understand what the compiler
is up to)

Three things make me think it's a bug in egcs:

* The assembler inner loop is MUCH shorter on my Alpha using OSF4.0 cxx.
* The assembler inner loop is MUCH shorter on my Alpha using egcs g77 and
corresponding fortran code.
* The assembler inner loop is MUCH shorter on my pentium with egcs 1.1.

egcs 1.1 on alpha gives more or less the same code as egcs-980921.

Results:
  snapshot-980921/bin/gcc -O3 -fstrict-aliasing -S --verbose-asm foo.cc

        .verstamp 3 11
        .set noreorder
        .set volatile
        .set noat
        .arch ev56
        .file   1 "foo.cc"
 # GNU C++ version egcs-2.91.57 19980901 (egcs-1.1 release)
(alphaev56-dec-osf4.
0d) compiled by GNU C version 2.8.1.
 # options passed:  -O3 -fstrict-aliasing -fverbose-asm
 # options enabled:  -fdefer-pop -fomit-frame-pointer -fcse-follow-jumps
 # -fcse-skip-blocks -fexpensive-optimizations -fthread-jumps
 # -fstrength-reduce -fpeephole -fforce-mem -ffunction-cse
 # -finline-functions -finline -fkeep-static-consts -fcaller-saves
 # -fpcc-struct-return -fgcse -frerun-cse-after-loop -frerun-loop-opt
 # -fschedule-insns -fschedule-insns2 -fsched-interblock -fsched-spec
 # -fexceptions -fsjlj-exceptions -fcommon -fverbose-asm -fregmove
 # -foptimize-register-move -fargument-alias -fstrict-aliasing
 # -mno-soft-float -mfp-regs -mbwx -mmemory-latency=L1

.text
        .align 5
        .globl main
        .ent main
main:
        .frame $30,500000,$26,0
$main..ng:
        bis $31,61,$23
        lda $22,4096($30)
$LSC0:
        stq $31,-8192($22)
        subq $23,1,$23
        lda $22,-8192($22)
        bne $23,$LSC0
        stq $31,-4384($22)
        lda $30,-4384($22)
        .prologue 0
        bis $31,$31,$7
        .align 4
$L5:
        bis $31,$31,$6
        s4addq $7,0,$8
        .align 4
$L9:
        bis $31,$31,$5
        .align 4
$L13:
        addq $8,$7,$1
        s4addl $1,$1,$1
        addq $1,$1,$1
        addq $1,$6,$3
        bis $3,$3,$2
        s4addq $3,0,$4
        bis $2,$2,$1
        addq $3,$4,$3
        addq $2,$4,$2
        addq $1,$4,$1
        s4addl $1,$1,$1
        s4addl $2,$2,$2
        addq $1,$1,$1
        addq $2,$2,$2
        addl $5,$1,$1
        addl $5,$2,$2
        s4addq $1,$30,$1
        s4addq $2,$30,$2
        lds $f11,0($1)
        lds $f10,0($2)
        s4addl $3,$3,$3
        muls $f11,$f10,$f11
        addq $3,$3,$3
        addl $5,$3,$3
        s4addq $3,$30,$3
        addl $5,1,$5
        cmple $5,49,$1
        sts $f11,0($3)
        bne $1,$L13
        addl $6,1,$6
        cmple $6,49,$1
        bne $1,$L9
        addl $7,1,$7
        cmple $7,49,$1
        bne $1,$L5
        bis $31,$31,$0
        ldah $23,8($30)
        lda $30,-24288($23)
        ret $31,($26),1
        .end main

Regards
/Oskar

*/              Oskar Enoksson, Linkoping, Sweden                  /*




More information about the Gcc-bugs mailing list