This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Alpha and -funroll-loops
- To: egcs at cygnus dot com
- Subject: Alpha and -funroll-loops
- From: Oskar Enoksson <osken393 at student dot liu dot se>
- Date: Mon, 21 Sep 1998 16:27:59 +0200 (MET DST)
Hi! I was just about to write an email complaining about the efficiency
of egcs code on Alpha CPU's when I discovered that -funroll-loops is the
magic that makes it run fast:
Results from the code on a 433 MHz ev56 with no L3-cache:
Compiler MFLOPS
========================================
Dec> f77 -O0 7
Dec> f77 -O1 44
Dec> f77 -O2 79
Dec> f77 -O3 208
Dec> f77 -O4 207
Dec> f77 -O5 113
egcs1.1> g77 -O0 12
egcs1.1> g77 -O1 71
egcs1.1> g77 -O2 83
egcs1.1> g77 -O3 83
egcs1.1> g77 -O3 -funroll-loops 187
The performance with snapshot 980914 was the same for this program.
In case someone is interested, I've attached some interesting pieces
of assembler output.
BTW, is it still true that -funroll-loops is unreliable for g++?
(The info-pages say so).
Regards.
/Oskar
program main
implicit none
integer ni,nj,nk
parameter (ni=50, nj=50, nk=50)
real a(ni,nj,nk)
real time0
integer i,j,k,n,nmax
integer flops
parameter (flops=100000000)
ccc Uncomment for use with DEC f77
c integer seed
nmax=flops/(ni*nj*nk)
ccc Uncomment for use with DEC f77
c seed=71891
do k=1,nk
do j=1,nj
do i=1,ni
ccc Uncomment for use with DEC f77
c a(i,j,k)=ran(seed)
ccc Uncomment for use with g77
a(i,j,k)=rand(1)
enddo
enddo
enddo
time0=Secnds(0.0)
do n=1,nmax
do k=1,nk
do j=1,nj
do i=1,ni
a(i,j,k)=2.*a(i,j,k)-.5*a(i,j,k)*a(i,j,k)*a(i,j,k)
enddo
enddo
enddo
enddo
write(*,*) 5*flops/(Secnds(0.0)-time0)/1000000, ' MFlops'
end
gcc-980914 -O3 -S
$L20:
bis $31,49,$10
bis $31,$31,$4
.align 4
$L24:
bis $31,49,$12
bis $31,$31,$3
subq $4,4,$5
.align 4
$L28:
addq $3,$5,$1
bis $31,49,$2
addq $1,$6,$1
addq $1,4,$1
.align 4
$L32:
lds $f10,0($1)
subl $2,1,$2
muls $f10,$f13,$f11
adds $f10,$f10,$f12
muls $f11,$f10,$f11
muls $f11,$f10,$f11
subs $f12,$f11,$f12
sts $f12,0($1)
addq $1,4,$1
bge $2,$L32
addq $3,200,$3
subl $12,1,$12
bge $12,$L28
lda $4,10000($4)
subl $10,1,$10
bge $10,$L24
subl $13,1,$13
bge $13,$L20
gcc-980914 -O3 -funroll-loops -S
$L20:
bis $31,49,$11
bis $31,$31,$4
.align 4
$L24:
bis $31,49,$12
bis $31,$31,$3
subq $4,4,$5
.align 4
$L28:
addq $3,$5,$1
bis $31,49,$2
addq $1,4,$1
.align 4
$L32:
lds $f14,0($1)
lds $f15,4($1)
lds $f22,8($1)
lds $f23,12($1)
lds $f24,16($1)
muls $f14,$f21,$f25
adds $f14,$f14,$f30
subl $2,5,$2
muls $f15,$f21,$f13
adds $f15,$f15,$f29
muls $f22,$f21,$f12
adds $f22,$f22,$f28
muls $f23,$f21,$f11
adds $f23,$f23,$f27
muls $f24,$f21,$f10
adds $f24,$f24,$f26
muls $f25,$f14,$f25
muls $f13,$f15,$f13
muls $f12,$f22,$f12
muls $f11,$f23,$f11
muls $f10,$f24,$f10
muls $f25,$f14,$f25
muls $f13,$f15,$f13
muls $f12,$f22,$f12
muls $f11,$f23,$f11
muls $f10,$f24,$f10
subs $f30,$f25,$f30
subs $f29,$f13,$f29
subs $f28,$f12,$f28
subs $f27,$f11,$f27
subs $f26,$f10,$f26
sts $f30,0($1)
sts $f29,4($1)
sts $f28,8($1)
sts $f27,12($1)
sts $f26,16($1)
addq $1,20,$1
bge $2,$L32
addq $3,200,$3
subl $12,1,$12
bge $12,$L28
lda $4,10000($4)
subl $11,1,$11
bge $11,$L24
subl $10,1,$10
bge $10,$L20
Dec OSF 4.0 f77 -O4 -S
L$8:
# 000030
mov 10000, $15
.loc 1 31
L$9:
# 000031
.loc 1 34
addq $11, $15, $12
# 000034
mov 200, $13
.loc 1 32
L$10:
# 000032
.loc 1 34
addq $12, $13, $9
# 000034
.loc 1 33
mov 1, $0
# 000033
.loc 1 34
lda $9, -10200($9)
# 000034
.loc 1 33
L$11:
# 000033
.loc 1 34
lds $f31, 128($9)
# 000034
lds $f11, ($9)
lds $f12, 4($9)
lds $f13, 8($9)
lds $f14, 12($9)
muls $f11, $f10, $f15
adds $f11, $f11, $f21
lds $f16, 16($9)
muls $f12, $f10, $f17
adds $f12, $f12, $f22
.loc 1 33
addl $0, 5, $0
# 000033
.loc 1 34
muls $f13, $f10, $f18
# 000034
adds $f13, $f13, $f23
.loc 1 33
cmple $0, 50, $2
# 000033
lda $9, 20($9)
.loc 1 34
muls $f14, $f10, $f19
# 000034
adds $f14, $f14, $f24
mov 10000, $3
muls $f16, $f10, $f20
muls $f15, $f11, $f15
adds $f16, $f16, $f25
muls $f17, $f12, $f17
muls $f18, $f13, $f18
muls $f19, $f14, $f19
muls $f20, $f16, $f20
muls $f15, $f11, $f11
muls $f17, $f12, $f12
muls $f18, $f13, $f13
muls $f19, $f14, $f14
muls $f20, $f16, $f16
subs $f21, $f11, $f11
subs $f22, $f12, $f12
subs $f23, $f13, $f13
subs $f24, $f14, $f14
subs $f25, $f16, $f16
sts $f11, -20($9)
sts $f12, -16($9)
sts $f13, -12($9)
sts $f14, -8($9)
sts $f16, -4($9)
.loc 1 33
bne $2, L$11
# 000033
.loc 1 32
lda $13, 200($13)
# 000032
cmple $13, $3, $3
bne $3, L$10
.loc 1 31
lda $15, 10000($15)
# 000031
cmple $15, $10, $4
bne $4, L$9
.loc 1 30
addl $14, 1, $14
# 000030
lda $5, -801($14)
blt $5, L$8