git subrepo pull --force deps/lightrec
[pcsx_rearmed.git] / deps / lightrec / optimizer.c
index 199ca40..cb9ba5b 100644 (file)
@@ -642,7 +642,7 @@ lightrec_remove_useless_lui(struct block *block, unsigned int offset,
                return;
        }
 
-       if (op->i.imm != 0 || op->i.rt == 0 || offset == block->nb_ops - 1)
+       if (op->i.imm != 0 || op->i.rt == 0 || is_delay_slot(list, offset))
                return;
 
        reader = find_next_reader(list, offset + 1, op->i.rt);
@@ -1002,10 +1002,10 @@ static int lightrec_transform_ops(struct lightrec_state *state, struct block *bl
                        break;
 
                case OP_LUI:
-                       if (i == 0 || !has_delay_slot(list[i - 1].c))
+                       if (!is_delay_slot(list, i))
                                lightrec_modify_lui(block, i);
                        lightrec_remove_useless_lui(block, i, v);
-                       if (i == 0 || !has_delay_slot(list[i - 1].c))
+                       if (!is_delay_slot(list, i))
                                lightrec_lui_to_movi(block, i);
                        break;
 
@@ -2099,7 +2099,7 @@ static int lightrec_flag_mults_divs(struct lightrec_state *state, struct block *
                        list->flags &= ~(LIGHTREC_NO_LO | LIGHTREC_NO_HI);
                }
 
-               if (reg_lo > 0 && reg_lo != REG_LO) {
+               if (0/* Broken */ && reg_lo > 0 && reg_lo != REG_LO) {
                        pr_debug("Found register %s to hold LO (rs = %u, rt = %u)\n",
                                 lightrec_reg_name(reg_lo), list->r.rs, list->r.rt);
 
@@ -2109,7 +2109,7 @@ static int lightrec_flag_mults_divs(struct lightrec_state *state, struct block *
                        list->r.rd = 0;
                }
 
-               if (reg_hi > 0 && reg_hi != REG_HI) {
+               if (0/* Broken */ && reg_hi > 0 && reg_hi != REG_HI) {
                        pr_debug("Found register %s to hold HI (rs = %u, rt = %u)\n",
                                 lightrec_reg_name(reg_hi), list->r.rs, list->r.rt);