Merge pull request #7051 from lioncash/frsqrte

Interpreter_FloatingPoint: Don't store to destination in frsqrte if VE or ZE is set and a relevant exception occurs
This commit is contained in:
Anthony 2018-06-02 13:49:09 -07:00 committed by GitHub
commit 0f7370a22c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 7 deletions

View File

@ -422,36 +422,43 @@ void Interpreter::fresx(UGeckoInstruction inst)
void Interpreter::frsqrtex(UGeckoInstruction inst) void Interpreter::frsqrtex(UGeckoInstruction inst)
{ {
const double b = rPS0(inst.FB); const double b = rPS0(inst.FB);
const double result = Common::ApproximateReciprocalSquareRoot(b);
const auto compute_result = [inst](double value) {
const double result = Common::ApproximateReciprocalSquareRoot(value);
rPS0(inst.FD) = result;
PowerPC::UpdateFPRF(result);
};
if (b < 0.0) if (b < 0.0)
{ {
SetFPException(FPSCR_VXSQRT); SetFPException(FPSCR_VXSQRT);
FPSCR.FI = 0;
FPSCR.FR = 0;
if (FPSCR.VE == 0) if (FPSCR.VE == 0)
PowerPC::UpdateFPRF(result); compute_result(b);
} }
else if (b == 0.0) else if (b == 0.0)
{ {
SetFPException(FPSCR_ZX); SetFPException(FPSCR_ZX);
if (FPSCR.ZE == 0) if (FPSCR.ZE == 0)
PowerPC::UpdateFPRF(result); compute_result(b);
} }
else if (Common::IsSNAN(b)) else if (Common::IsSNAN(b))
{ {
SetFPException(FPSCR_VXSNAN); SetFPException(FPSCR_VXSNAN);
FPSCR.FI = 0;
FPSCR.FR = 0;
if (FPSCR.VE == 0) if (FPSCR.VE == 0)
PowerPC::UpdateFPRF(result); compute_result(b);
} }
else else
{ {
PowerPC::UpdateFPRF(result); compute_result(b);
} }
rPS0(inst.FD) = result;
if (inst.Rc) if (inst.Rc)
Helper_UpdateCR1(); Helper_UpdateCR1();
} }