From: Przemek Klosowski <przemek@rrdjazz.nist.gov>
Subject: Re: profiles of gcc available
Date: Wed, 13 Nov 1996 17:40:34 -0500 [thread overview]
Message-ID: <199611132240.RAA19556@rrdjazz.nist.gov> (raw)
A simple example suffices - compile the following on your x86 box
and on an ALPHA, say with -O2:
void copy(char *s, char *d)
{
while (*d++ = *s++)
;
}
This code uses three instructions in the loop on my m68k machine -
including the jump (which is one more than necessary). I would be
surprised if the number of instructions on an ALPHA would be less
than ten. On the granddaddy of supercomputers, the Cray Y-MP, it
takes over 80 instructions.
That is an interesting exercise in watching compiler microoptimization.
On Intel, gcc 2.7.2 -O2, this is translated to
.L7:
movb (%ecx),%al
movb %al,(%edx)
incl %ecx
incl %edx
testb %al,%al
jne .L7
Since there is no autoincrement mode on Intel, the increments have to be there.
I don't know enough of Intel assembly language to tell if it can be improved upon.
BTW, gcc without optimization does a jump to a jump at the end of the loop; the
rest of the code is identical.
On Alpha/Linux, using the same version of gcc, the above code is
$34:
ldq_u $3,0($16)
ldq_u $2,0($17)
extbl $3,$16,$3
mskbl $2,$17,$2
insbl $3,$17,$1
addq $16,1,$16
bis $1,$2,$1
stq_u $1,0($17)
addq $17,1,$17
bne $3,$34
while on Alpha/Digital using DEC cc:
# 3 while (*d++ = *s++)
.set noat
lda $28, 1($16)
ldq_u $0, 0($16)
extqh $0, $28, $0
sra $0, 56, $0
.set at
.set noat
ldq_u $28, 0($17)
insbl $0, $17, $1
mskbl $28, $17, $28
bis $28, $1, $28
stq_u $28, 0($17)
.set at
addq $17, 1, $17
addq $16, 1, $16
beq $0, $33
.align 3
$32:
.loc 2 4
# 4 ;
.set noat
lda $28, 1($16)
ldq_u $0, 0($16)
extqh $0, $28, $0
sra $0, 56, $0
.set at
.set noat
ldq_u $28, 0($17)
insbl $0, $17, $2
mskbl $28, $17, $28
bis $28, $2, $28
stq_u $28, 0($17)
.set at
addq $17, 1, $17
addq $16, 1, $16
bne $0, $32
.loc 2 5
# 5 }
$33:
Funny, the DEC version doesn't strike me as faster, even if it fills
latencies/scheduling better (I haven't timed it, though).
p
--
To unsubscribe: send e-mail to axp-list-request@redhat.com with
'unsubscribe' as the subject. Do not send it to axp-list@redhat.com
next reply other threads:[~1996-11-13 22:40 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
1996-11-13 22:40 Przemek Klosowski [this message]
-- strict thread matches above, loose matches on Subject: below --
1996-11-13 16:41 profiles of gcc available Toon Moene
1996-11-12 22:51 Toon Moene
1996-11-13 4:48 ` Richard Henderson
1996-11-12 13:36 Jim Nance
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox