Skip to content

Commit

Permalink
Merge pull request #7051 from lioncash/frsqrte
Browse files Browse the repository at this point in the history
Interpreter_FloatingPoint: Don't store to destination in frsqrte if VE or ZE is set and a relevant exception occurs
  • Loading branch information
Helios747 committed Jun 2, 2018
2 parents ba471c3 + 21add26 commit 0f7370a
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions Source/Core/Core/PowerPC/Interpreter/Interpreter_FloatingPoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -422,36 +422,43 @@ void Interpreter::fresx(UGeckoInstruction inst)
void Interpreter::frsqrtex(UGeckoInstruction inst)
{
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)
{
SetFPException(FPSCR_VXSQRT);
FPSCR.FI = 0;
FPSCR.FR = 0;

if (FPSCR.VE == 0)
PowerPC::UpdateFPRF(result);
compute_result(b);
}
else if (b == 0.0)
{
SetFPException(FPSCR_ZX);

if (FPSCR.ZE == 0)
PowerPC::UpdateFPRF(result);
compute_result(b);
}
else if (Common::IsSNAN(b))
{
SetFPException(FPSCR_VXSNAN);
FPSCR.FI = 0;
FPSCR.FR = 0;

if (FPSCR.VE == 0)
PowerPC::UpdateFPRF(result);
compute_result(b);
}
else
{
PowerPC::UpdateFPRF(result);
compute_result(b);
}

rPS0(inst.FD) = result;

if (inst.Rc)
Helper_UpdateCR1();
}
Expand Down

0 comments on commit 0f7370a

Please sign in to comment.