diff --git a/Source/Core/Core/Src/PowerPC/Interpreter/Interpreter_FloatingPoint.cpp b/Source/Core/Core/Src/PowerPC/Interpreter/Interpreter_FloatingPoint.cpp index c5fa330cab..7ecd40db3a 100644 --- a/Source/Core/Core/Src/PowerPC/Interpreter/Interpreter_FloatingPoint.cpp +++ b/Source/Core/Core/Src/PowerPC/Interpreter/Interpreter_FloatingPoint.cpp @@ -59,8 +59,24 @@ void fcmpo(UGeckoInstruction _inst) double fb = rPS0(_inst.FB); int compareResult; - if (IsNAN(fa) || IsNAN(fb)) + //if (IsNAN(fa) || IsNAN(fb)) + //{ + // FPSCR.FX = 1; + // compareResult = 1; + // if (IsSNAN(fa) || IsSNAN(fb)) + // { + // FPSCR.VXSNAN = 1; + // if (!FPSCR.FEX || IsQNAN(fa) || IsQNAN(fb)) + // FPSCR.VXVC = 1; + // } + //} + //else + if (fa < fb) compareResult = 8; + else if (fa > fb) compareResult = 4; + else if (fa == fb) compareResult = 2; + else { + // either fa or fb is NaN, or both, FPSCR.FX = 1; compareResult = 1; if (IsSNAN(fa) || IsSNAN(fb)) @@ -69,10 +85,8 @@ void fcmpo(UGeckoInstruction _inst) if (!FPSCR.FEX || IsQNAN(fa) || IsQNAN(fb)) FPSCR.VXVC = 1; } + } - else if (fa < fb) compareResult = 8; - else if (fa > fb) compareResult = 4; - else compareResult = 2; FPSCR.FPRF = compareResult; SetCRField(_inst.CRFD, compareResult); @@ -86,8 +100,22 @@ void fcmpu(UGeckoInstruction _inst) double fb = rPS0(_inst.FB); int compareResult; - if (IsNAN(fa) || IsNAN(fb)) + //if (IsNAN(fa) || IsNAN(fb)) + //{ + // FPSCR.FX = 1; + // compareResult = 1; + // if (IsSNAN(fa) || IsSNAN(fb)) + // { + // FPSCR.VXSNAN = 1; + // } + //} + //else + if (fa < fb) compareResult = 8; + else if (fa > fb) compareResult = 4; + else if (fa == fb) compareResult = 2; + else { + // either fa or fb is NaN, or both FPSCR.FX = 1; compareResult = 1; if (IsSNAN(fa) || IsSNAN(fb)) @@ -95,9 +123,6 @@ void fcmpu(UGeckoInstruction _inst) FPSCR.VXSNAN = 1; } } - else if (fa < fb) compareResult = 8; - else if (fa > fb) compareResult = 4; - else compareResult = 2; FPSCR.FPRF = compareResult; SetCRField(_inst.CRFD, compareResult); diff --git a/Source/Core/Core/Src/PowerPC/Interpreter/Interpreter_Paired.cpp b/Source/Core/Core/Src/PowerPC/Interpreter/Interpreter_Paired.cpp index 004a3dbcb9..36120cfeab 100644 --- a/Source/Core/Core/Src/PowerPC/Interpreter/Interpreter_Paired.cpp +++ b/Source/Core/Core/Src/PowerPC/Interpreter/Interpreter_Paired.cpp @@ -29,10 +29,14 @@ namespace Interpreter // These "binary instructions" do not alter FPSCR. void ps_sel(UGeckoInstruction _inst) { - rPS0(_inst.FD) = !IsNAN(rPS0(_inst.FA)) && rPS0(_inst.FA) >= -0.0 ? - rPS0(_inst.FC) : rPS0(_inst.FB); - rPS1(_inst.FD) = !IsNAN(rPS1(_inst.FA)) && rPS1(_inst.FA) >= -0.0 ? - rPS1(_inst.FC) : rPS1(_inst.FB); + //rPS0(_inst.FD) = !IsNAN(rPS0(_inst.FA)) && rPS0(_inst.FA) >= -0.0 ? + // rPS0(_inst.FC) : rPS0(_inst.FB); + //rPS1(_inst.FD) = !IsNAN(rPS1(_inst.FA)) && rPS1(_inst.FA) >= -0.0 ? + // rPS1(_inst.FC) : rPS1(_inst.FB); + + // no need to check isNaN + rPS0(_inst.FD) = rPS0(_inst.FA) >= -0.0 ? rPS0(_inst.FC) : rPS0(_inst.FB); + rPS1(_inst.FD) = rPS1(_inst.FA) >= -0.0 ? rPS1(_inst.FC) : rPS1(_inst.FB); if (_inst.Rc) Helper_UpdateCR1(rPS0(_inst.FD)); } @@ -243,10 +247,12 @@ void ps_cmpu0(UGeckoInstruction _inst) double fa = rPS0(_inst.FA); double fb = rPS0(_inst.FB); int compareResult; - if (IsNAN(fa) || IsNAN(fb)) compareResult = 1; - else if (fa < fb) compareResult = 8; + //if (IsNAN(fa) || IsNAN(fb)) compareResult = 1; + //else + if (fa < fb) compareResult = 8; else if (fa > fb) compareResult = 4; - else compareResult = 2; + else if (fa == fb) compareResult = 2; + else compareResult = 1; SetCRField(_inst.CRFD, compareResult); if (_inst.Rc) Helper_UpdateCR1(rPS0(_inst.FD)); } @@ -262,10 +268,12 @@ void ps_cmpu1(UGeckoInstruction _inst) double fa = rPS1(_inst.FA); double fb = rPS1(_inst.FB); int compareResult; - if (IsNAN(fa) || IsNAN(fb)) compareResult = 1; - else if (fa < fb) compareResult = 8; + //if (IsNAN(fa) || IsNAN(fb)) compareResult = 1; + //else + if (fa < fb) compareResult = 8; else if (fa > fb) compareResult = 4; - else compareResult = 2; + else if (fa == fb) compareResult = 2; + else compareResult = 1; SetCRField(_inst.CRFD, compareResult); if (_inst.Rc) Helper_UpdateCR1(rPS0(_inst.FD)); }