This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/58092] BEQ (Branch on equal) jumps to wrong address (executes conditional code!)


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]