This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/58092] BEQ (Branch on equal) jumps to wrong address (executes conditional code!)
- From: "zajec5 at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 06 Aug 2013 12:17:34 +0000
- Subject: [Bug c/58092] BEQ (Branch on equal) jumps to wrong address (executes conditional code!)
- Auto-submitted: auto-generated
- References: <bug-58092-4 at http dot gcc dot gnu dot org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58092
--- Comment #2 from RafaÅ MiÅecki <zajec5 at gmail dot com> ---
### Decompiled object ###
00000000 <test>:
0: 24020002 li v0,2
4: 24030004 li v1,4
8: aca20000 sw v0,0(a1)
c: 10830002 beq a0,v1,18 <test+0x18>
10: 24020008 li v0,8
14: 8ca20040 lw v0,64(a1)
18: aca20040 sw v0,64(a1)
1c: 03e00008 jr ra
20: 00000000 nop
### Decompiled with my explanations ###
0: 24020002 li v0,2
4: 24030004 li v1,4
8: aca20000 sw v0,0(a1)
v0 (0x2) is stored in a1 unconditionally - this is fine
c: 10830002 beq a0,v1,18 <test+0x18>
10: 24020008 li v0,8
a0 (rev argument) is compared with v1 (0x4) - if equal CPU jumps to 0x18
14: 8ca20040 lw v0,64(a1)
the above line is executed to rev != 4
18: aca20040 sw v0,64(a1)
the above lins (store v0 in a1+64) is always executed!
it should be executed for rev==4 only
v0 is 0x8 by default, or some different value for rev != 4
1c: 03e00008 jr ra
20: 00000000 nop