Missed optimization in m68k
Peter Barada
pbarada@mail.wm.sps.mot.com
Fri Jun 14 12:30:00 GMT 2002
I'm compiling the small snippet:
char *copy(const char *src, char *dst)
{
char *dst0 = dst;
while (*dst++ = *src++)
;
return dst0;
}
And when compiled with 3.0.4 I get:
copy:
move.l 4(%sp),%a1
move.l 8(%sp),%a0
move.l %a0,%d0
.L2:
move.b (%a1)+,(%a0)
tst.b (%a0)+
jbne .L2
rts
The problem is that the tst.b is not necessary since the move.b
updated the condition codes as part of the move. How can I best
convince gcc that it should generate the follwing instead:
copy:
move.l 4(%sp),%a1
move.l 8(%sp),%a0
move.l %a0,%d0
.L2:
move.b (%a1)+,(%a0)+
jbne .L2
rts
Thanx...
--
Peter Barada Peter.Barada@motorola.com
Wizard 781-852-2768 (direct)
WaveMark Solutions(wholly owned by Motorola) 781-270-0193 (fax)
More information about the Gcc
mailing list