Interpreter_FloatingPoint: Don't update the FPRF in fres in certain exceptional cases

If FPSCR.ZE is set and a divide by zero exception is signaled, then the
FPRF shouldn't be updated with a result. Similarly, if the input is an
SNaN and FPSCR.VE is set, then the FPRF shouldn't be updated.
This commit is contained in:
Lioncash 2018-05-23 23:31:56 -04:00
parent 8a79f9099c
commit 34adc529a7
1 changed files with 14 additions and 5 deletions

View File

@ -395,19 +395,28 @@ void Interpreter::fdivsx(UGeckoInstruction inst)
void Interpreter::fresx(UGeckoInstruction inst) void Interpreter::fresx(UGeckoInstruction inst)
{ {
const double b = rPS0(inst.FB); const double b = rPS0(inst.FB);
rPS0(inst.FD) = rPS1(inst.FD) = Common::ApproximateReciprocal(b); const double result = Common::ApproximateReciprocal(b);
rPS0(inst.FD) = rPS1(inst.FD) = result;
if (b == 0.0) if (b == 0.0)
{ {
SetFPException(FPSCR_ZX); SetFPException(FPSCR_ZX);
}
if (Common::IsSNAN(b)) if (FPSCR.ZE == 0)
PowerPC::UpdateFPRF(result);
}
else if (Common::IsSNAN(b))
{ {
SetFPException(FPSCR_VXSNAN); SetFPException(FPSCR_VXSNAN);
}
PowerPC::UpdateFPRF(rPS0(inst.FD)); if (FPSCR.VE == 0)
PowerPC::UpdateFPRF(result);
}
else
{
PowerPC::UpdateFPRF(result);
}
if (inst.Rc) if (inst.Rc)
Helper_UpdateCR1(); Helper_UpdateCR1();