From: notaz Date: Wed, 22 Jan 2025 01:11:12 +0000 (+0200) Subject: drc: detect unoptimized stack reloads X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cf8401830df21650d93b38d2bcaf58dcc80c29d4;p=pcsx_rearmed.git drc: detect unoptimized stack reloads --- diff --git a/libpcsxcore/new_dynarec/new_dynarec.c b/libpcsxcore/new_dynarec/new_dynarec.c index 9b090e4b..86333a86 100644 --- a/libpcsxcore/new_dynarec/new_dynarec.c +++ b/libpcsxcore/new_dynarec/new_dynarec.c @@ -7434,6 +7434,17 @@ static noinline void pass2a_unneeded_other(void) break; } } + // rm redundant stack loads (unoptimized code, assuming no io mem access through sp) + if (i > 0 && dops[i].is_load && dops[i].rs1 == 29 && dops[i].ls_type == LS_32 + && dops[i-1].is_store && dops[i-1].rs1 == 29 && dops[i-1].ls_type == LS_32 + && dops[i-1].rs2 == dops[i].rt1 && !dops[i-1].is_ds && i < slen - 1 + && dops[i+1].rs1 != dops[i].rt1 && dops[i+1].rs2 != dops[i].rt1 + && !dops[i].bt && cinfo[i].imm == cinfo[i-1].imm) + { + cinfo[i].imm = 0; + memset(&dops[i], 0, sizeof(dops[i])); + dops[i].itype = NOP; + } } }