Can the instruction scheduler actually rewrite instructions? I didn't
think so but when I compile some code on MIPS with:
-O2 -fno-ivopts -fno-peephole2 -fno-schedule-insns2
I get:
$L4:
lbu $3,0($4)
addiu $4,$4,1
lbu $2,0($5)
beq $3,$0,$L7
addiu $5,$5,1
beq $3,$2,$L4
subu $2,$3,$2
When I changed -fno-schedule-insns2 to -fschedule-insns2, I get:
$L4:
lbu $3,0($4)
addiu $5,$5,1
lbu $2,-1($5)
beq $3,$0,$L7
addiu $4,$4,1
beq $3,$2,$L4
subu $2,$3,$2
I.e. The addiu of $5 and the load using $5 have been swapped around
and the load uses a different offset to compensate. I can't see
where in the instruction scheduler that this would happen. Any
help? This is on MIPS if that matters, though I didn't see any
MIPS specific code for this. This issue is related to my earlier
question about PR 48814 and ivopts (thus the -fno-ivopts option).
The C code I am looking at is the strcmp function from glibc:
int
strcmp (const char *p1, const char *p2)
{
const unsigned char *s1 = (const unsigned char *) p1;
const unsigned char *s2 = (const unsigned char *) p2;
unsigned char c1, c2;
do
{
c1 = (unsigned char) *s1++;
c2 = (unsigned char) *s2++;
if (c1 == '\0')
return c1 - c2;
}
while (c1 == c2);
return c1 - c2;
}
Steve Ellcey
[email protected]