This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Is the new jump processing really better?
- To: gcc at gcc dot gnu dot org
- Subject: Is the new jump processing really better?
- From: Brad Lucier <lucier at math dot purdue dot edu>
- Date: Thu, 18 May 2000 01:19:32 -0500 (EST)
- Cc: lucier at math dot purdue dot edu (Brad Lucier)
There have been many recent changes to the code to handle jumps, but I'm wondering if
it's all for the better.
For this function:
void
f (double* a, int n)
{
int i = n;
if (i < 0)
goto exit;
top:
if (a[i] <= 0.0)
goto nonpositive;
a[i] = 2.0 * a[i];
i = i - 1;
if (i < 0)
goto exit;
else
goto top;
nonpositive:
if (a[i] < 0.0)
goto negative;
a[i] = 1.0;
if (i < 0)
goto exit;
else
goto top;
negative:
a[i] = 3.0 * a[i];
i = i - 1;
if (i < 0)
goto exit;
else
goto top;
exit:
}
gcc-2.95.1 on alpha-ev6-unknown-linux with options -mcpu=ev6 -mieee -fPIC -O2 gives
.file 1 "test-loop.c"
.set noat
.set noreorder
.arch ev6
.section .rodata
.align 3
$LC0:
.t_floating 1.00000000000000000000e0
.align 3
$LC1:
.t_floating 3.00000000000000000000e0
.text
.align 5
.globl f
.ent f
f:
.eflag 48
.frame $30,0,$26,0
ldgp $29,0($27)
$f..ng:
.prologue 1
$L16:
blt $17,$L4
$L5:
s8addq $17,$16,$2
ldt $f11,0($2)
cmptlesu $f11,$f31,$f10
fbne $f10,$L7
addtsu $f11,$f11,$f10
subl $17,1,$17
stt $f10,0($2)
br $31,$L16
.align 4
$L7:
cmptltsu $f11,$f31,$f10
fbne $f10,$L11
lda $1,$LC0
ldt $f10,0($1)
stt $f10,0($2)
br $31,$L16
.align 4
$L11:
lda $1,$LC1
subl $17,1,$17
ldt $f10,0($1)
multsu $f11,$f10,$f12
fmov $f12,$f11
stt $f11,0($2)
bge $17,$L5
$L4:
ret $31,($26),1
.end f
.ident "GCC: (GNU) 2.95.1 19990816 (release)"
Notice that there's only one executed jump at the end of each arm of the simulated if,
to the test at the top of the loop.
Today's CVS snapshot gives:
.file 1 "test-loop.c"
.set noat
.set noreorder
.arch ev6
.section .rodata
.align 3
$LC0:
.quad 0x3ff0000000000000
.align 3
$LC1:
.quad 0x4008000000000000
.text
.align 4
.globl f
.ent f
f:
.eflag 48
.frame $30,0,$26,0
ldgp $29,0($27)
$f..ng:
.prologue 1
blt $17,$L4
s8addq $17,0,$2
$L5:
addq $2,$16,$1
ldt $f12,0($1)
cmptlesu $f12,$f31,$f10
fbne $f10,$L8
addtsu $f12,$f12,$f10
subl $17,1,$17
s8addq $17,0,$2
br $31,$L20
.align 4
$L8:
cmptltsu $f12,$f31,$f10
lda $4,$LC1
lda $3,$LC0
fbne $f10,$L13
ldt $f10,0($3)
br $31,$L20
.align 4
$L13:
ldt $f11,0($4)
subl $17,1,$17
s8addq $17,0,$2
multsu $f12,$f11,$f10
$L20:
stt $f10,0($1)
bge $17,$L5
$L4:
ret $31,($26),1
.end f
.ident "GCC: (GNU) 2.96 20000517 (experimental)"
which requires two jumps, to $L20 and then to $L5 for the first two
arms of the simulated if. This seems worse to me---a small bit of space
savings at the cost of an extra jump.
Brad Lucier