This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
PR/7896: [H8300] C compiler generates wrong code
- From: tm <tm at mail dot kloo dot net>
- To: jmueller at hanoverdisplays dot com
- Cc: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 16 Oct 2002 13:38:21 -0700 (PDT)
- Subject: PR/7896: [H8300] C compiler generates wrong code
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