PR/7896: [H8300] C compiler generates wrong code
tm
tm@mail.kloo.net
Wed Oct 16 13:45:00 GMT 2002
This code looks correct:
_bla:
push.l er4
mov.w r0,r4
subs #1,er4
beq .L7
.L5:
mov.l er4,@-er7
mov.l #.LC0,er2
mov.l er2,@-er7
mov.l @__impure_ptr,er2
mov.l @(8,er2),er0
jsr @_fprintf
adds #4,er7
adds #4,er7
mov.w r4,r2
subs #1,er4
bne .L5
.L7:
pop.l er4
rts
The value of er4 is tested before er4 is decremented.
The instruction:
subs #1,er4
does not affect the Z flag according to my H8/300H series manual
page 180.
So therefore the Z flag is set by the previous:
mov.w r0,r4
or
mov.w r4,r2
and therefore the code seems to be correct.
Toshi
More information about the Gcc-bugs
mailing list