X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=deps%2Flightrec%2Foptimizer.c;h=cb9ba5b87a58fa44761f4f604a5014bb26bc1ad3;hb=878e6cda26bbf4af5090a01709db026d42c233b4;hp=90b21398c519ced986d59c7802ea94366e2321da;hpb=2b1b10dd333f8b525b90a15468824aae0ff4eb2f;p=pcsx_rearmed.git diff --git a/deps/lightrec/optimizer.c b/deps/lightrec/optimizer.c index 90b21398..cb9ba5b8 100644 --- a/deps/lightrec/optimizer.c +++ b/deps/lightrec/optimizer.c @@ -299,6 +299,9 @@ static bool reg_is_dead(const struct opcode *list, unsigned int offset, u8 reg) if (opcode_writes_register(list[i].c, reg)) return true; + if (is_syscall(list[i].c)) + return false; + if (has_delay_slot(list[i].c)) { if (op_flag_no_ds(list[i].flags) || opcode_reads_register(list[i + 1].c, reg)) @@ -342,7 +345,7 @@ static bool reg_is_read_or_written(const struct opcode *list, return reg_is_read(list, a, b, reg) || reg_is_written(list, a, b, reg); } -bool opcode_is_mfc(union code op) +static bool opcode_is_mfc(union code op) { switch (op.i.op) { case OP_CP0: @@ -374,7 +377,7 @@ bool opcode_is_mfc(union code op) return false; } -bool opcode_is_load(union code op) +static bool opcode_is_load(union code op) { switch (op.i.op) { case OP_LB: @@ -408,6 +411,12 @@ static bool opcode_is_store(union code op) } } +bool opcode_has_load_delay(union code op) +{ + return (opcode_is_load(op) && op.i.rt && op.i.op != OP_LWC2) + || opcode_is_mfc(op); +} + static u8 opcode_get_io_size(union code op) { switch (op.i.op) { @@ -633,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); @@ -993,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; @@ -1382,7 +1391,7 @@ static int lightrec_handle_load_delays(struct lightrec_state *state, for (i = 0; i < block->nb_ops; i++) { op = &list[i]; - if (!opcode_is_load(op->c) || !op->c.i.rt || op->c.i.op == OP_LWC2) + if (!opcode_has_load_delay(op->c)) continue; if (!is_delay_slot(list, i)) { @@ -2090,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); @@ -2100,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);