mirror of
https://github.com/N64Recomp/N64Recomp.git
synced 2026-05-08 01:41:46 +00:00
Fixed edge case with switch case jump table detection when lo16 immediate is exactly 0
This commit is contained in:
parent
14f5d78157
commit
305cc76448
1 changed files with 4 additions and 2 deletions
|
|
@ -158,9 +158,11 @@ bool analyze_instruction(const rabbitizer::InstructionCpu& instr, const N64Recom
|
||||||
}
|
}
|
||||||
// If the base register has a valid lui state and a valid addend before this, then this may be a load from a jump table
|
// If the base register has a valid lui state and a valid addend before this, then this may be a load from a jump table
|
||||||
else if (reg_states[base].valid_lui && reg_states[base].valid_addend) {
|
else if (reg_states[base].valid_lui && reg_states[base].valid_addend) {
|
||||||
// Exactly one of the lw and the base reg should have a valid lo16 value
|
// Exactly one of the lw and the base reg should have a valid lo16 value. However, the lo16 may end up just being zero by pure luck,
|
||||||
|
// so allow the case where the lo16 immediate is zero and the register state doesn't have a valid addiu immediate.
|
||||||
|
// This means the only invalid case is where they're both true.
|
||||||
bool nonzero_immediate = imm != 0;
|
bool nonzero_immediate = imm != 0;
|
||||||
if (nonzero_immediate != reg_states[base].valid_addiu) {
|
if (!(nonzero_immediate && reg_states[base].valid_addiu)) {
|
||||||
uint32_t lo16;
|
uint32_t lo16;
|
||||||
if (nonzero_immediate) {
|
if (nonzero_immediate) {
|
||||||
lo16 = (int16_t)imm;
|
lo16 = (int16_t)imm;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue