X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=deps%2Flightrec%2Foptimizer.c;h=90b21398c519ced986d59c7802ea94366e2321da;hb=0096868ecb1c7403b76847010d4fb6a1a827110b;hp=c01e024bb168e14a8cc37270fb2bd34ed57c94e8;hpb=f5ee77cadf78d389ce40f00988ee9bde1d567dc7;p=pcsx_rearmed.git diff --git a/deps/lightrec/optimizer.c b/deps/lightrec/optimizer.c index c01e024b..90b21398 100644 --- a/deps/lightrec/optimizer.c +++ b/deps/lightrec/optimizer.c @@ -114,6 +114,8 @@ static u64 opcode_read_mask(union code op) case OP_SWL: case OP_SW: case OP_SWR: + case OP_META_LWU: + case OP_META_SWU: return BIT(op.i.rs) | BIT(op.i.rt); case OP_META: return BIT(op.m.rs); @@ -186,6 +188,7 @@ u64 opcode_write_mask(union code op) case OP_LBU: case OP_LHU: case OP_LWR: + case OP_META_LWU: return BIT(op.i.rt); case OP_JAL: return BIT(31); @@ -382,6 +385,7 @@ bool opcode_is_load(union code op) case OP_LHU: case OP_LWR: case OP_LWC2: + case OP_META_LWU: return true; default: return false; @@ -397,6 +401,7 @@ static bool opcode_is_store(union code op) case OP_SWL: case OP_SWR: case OP_SWC2: + case OP_META_SWU: return true; default: return false; @@ -438,6 +443,7 @@ static bool is_nop(union code op) case OP_LBU: case OP_LHU: case OP_LWR: + case OP_META_LWU: return false; default: return true; @@ -822,6 +828,7 @@ static void lightrec_patch_known_zero(struct opcode *op, case OP_SWL: case OP_SW: case OP_SWR: + case OP_META_SWU: if (is_known_zero(v, op->i.rt)) op->i.rt = 0; fallthrough; @@ -834,6 +841,7 @@ static void lightrec_patch_known_zero(struct opcode *op, case OP_LWR: case OP_LWC2: case OP_SWC2: + case OP_META_LWU: if (is_known(v, op->i.rs) && kunseg(v[op->i.rs].value) == 0) op->i.rs = 0; @@ -879,6 +887,7 @@ static int lightrec_transform_ops(struct lightrec_state *state, struct block *bl struct constprop_data v[32] = LIGHTREC_CONSTPROP_INITIALIZER; unsigned int i; bool local; + int idx; u8 tmp; for (i = 0; i < block->nb_ops; i++) { @@ -1016,6 +1025,40 @@ static int lightrec_transform_ops(struct lightrec_state *state, struct block *bl } } break; + case OP_LWL: + case OP_LWR: + if (i == 0 || !has_delay_slot(list[i - 1].c)) { + idx = find_next_reader(list, i + 1, op->i.rt); + if (idx > 0 && list[idx].i.op == (op->i.op ^ 0x4) + && list[idx].i.rs == op->i.rs + && list[idx].i.rt == op->i.rt + && abs((s16)op->i.imm - (s16)list[idx].i.imm) == 3) { + /* Replace a LWL/LWR combo with a META_LWU */ + if (op->i.op == OP_LWL) + op->i.imm -= 3; + op->i.op = OP_META_LWU; + list[idx].opcode = 0; + pr_debug("Convert LWL/LWR to LWU\n"); + } + } + break; + case OP_SWL: + case OP_SWR: + if (i == 0 || !has_delay_slot(list[i - 1].c)) { + idx = find_next_reader(list, i + 1, op->i.rt); + if (idx > 0 && list[idx].i.op == (op->i.op ^ 0x4) + && list[idx].i.rs == op->i.rs + && list[idx].i.rt == op->i.rt + && abs((s16)op->i.imm - (s16)list[idx].i.imm) == 3) { + /* Replace a SWL/SWR combo with a META_SWU */ + if (op->i.op == OP_SWL) + op->i.imm -= 3; + op->i.op = OP_META_SWU; + list[idx].opcode = 0; + pr_debug("Convert SWL/SWR to SWU\n"); + } + } + break; case OP_REGIMM: switch (op->r.rt) { case OP_REGIMM_BLTZ: