Skip to content

Commit

Permalink
Merge pull request #18165 from unknownbrackets/x64-ir-bmi2
Browse files Browse the repository at this point in the history
x86jit: Fix flush for special-purpose reg
  • Loading branch information
hrydgard committed Sep 17, 2023
2 parents 99b2d2b + 07150b5 commit 92d1a66
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
8 changes: 4 additions & 4 deletions Core/MIPS/IR/IRFrontend.cpp
Expand Up @@ -339,8 +339,8 @@ void IRFrontend::CheckBreakpoint(u32 addr) {
if (CBreakPoints::IsAddressBreakPoint(addr)) {
FlushAll();

if (GetCompilerPC() != js.blockStart)
ir.Write(IROp::SetPCConst, 0, ir.AddConstant(GetCompilerPC()));
// Can't skip this even at the start of a block, might impact block linking.
ir.Write(IROp::SetPCConst, 0, ir.AddConstant(GetCompilerPC()));

RestoreRoundingMode();
// At this point, downcount HAS the delay slot, but not the instruction itself.
Expand Down Expand Up @@ -370,8 +370,8 @@ void IRFrontend::CheckMemoryBreakpoint(int rs, int offset) {
if (CBreakPoints::HasMemChecks()) {
FlushAll();

if (GetCompilerPC() != js.blockStart)
ir.Write(IROp::SetPCConst, 0, ir.AddConstant(GetCompilerPC()));
// Can't skip this even at the start of a block, might impact block linking.
ir.Write(IROp::SetPCConst, 0, ir.AddConstant(GetCompilerPC()));

RestoreRoundingMode();
// At this point, downcount HAS the delay slot, but not the instruction itself.
Expand Down
19 changes: 15 additions & 4 deletions Core/MIPS/x86/X64IRRegCache.cpp
Expand Up @@ -222,14 +222,25 @@ void X64IRRegCache::MapWithFlags(IRInst inst, X64Map destFlags, X64Map src1Flags
mapping[2].flags = mapping[2].flags | src2Flags;

auto flushReg = [&](IRNativeReg nreg) {
bool mustKeep = false;
bool canDiscard = false;
for (int i = 0; i < 3; ++i) {
if (mapping[i].reg == nr[nreg].mipsReg && (mapping[i].flags & MIPSMap::NOINIT) == MIPSMap::NOINIT) {
DiscardNativeReg(nreg);
return;
if (mapping[i].reg != nr[nreg].mipsReg)
continue;

if ((mapping[i].flags & MIPSMap::NOINIT) != MIPSMap::NOINIT) {
mustKeep = true;
break;
} else {
canDiscard = true;
}
}

FlushNativeReg(nreg);
if (mustKeep || !canDiscard) {
FlushNativeReg(nreg);
} else {
DiscardNativeReg(nreg);
}
};

// If there are any special rules, we might need to spill.
Expand Down

0 comments on commit 92d1a66

Please sign in to comment.