mkst / maspsx

MIT License
5 stars 4 forks source link

Another mismatching NOP #22

Closed bismurphy closed 1 year ago

bismurphy commented 1 year ago

Hi!

As part of the SOTN decomp, I've been working on a large function, and I've found a divergence in maspsx's output.

Here is a decomp.me scratch: https://decomp.me/scratch/gAkz5

If you scroll to assembly line 434, there is an extra NOP inserted, likely as a result of having a lw instruction immediately followed by another instruction which uses that same register. With the settings as-is, this NOP is missing from the compiled code. Changing the Options to use the SOTN preset on decomp.me restores the NOP, which I believe indicates that this is a maspsx issue.

mkst commented 1 year ago

On master I see the missing nop here: image

This code should have a nop between the lw and lhu:

    li  $19,0x1f800000      # 528482304
    lw  $2,528482500        # 0x1f8000c4
    #nop
    addu    $3,$9,$2

    .loc    1 158

This code should NOT have a nop between the lw and lhu

    li  $19,0x1f800000      # 528482304
    lw  $2,528482508

    .loc    1 161
LM102:
    lhu $11,16($sp)

In the first example, the li/lw combo loads a 32bit value, and the following instruction uses the destination register. In the second example the destination register is unused.