summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorRyan Houdek <Sonicadvance1@gmail.com>2014-09-20 12:40:55 -0500
committerRyan Houdek <Sonicadvance1@gmail.com>2014-09-20 12:40:55 -0500
commita829e596c755139b4c323b9dcd7b82bf2de4deb2 (patch)
tree08ecbb02f62074c6c3b020b244c4cb6f56e81c6e /Source/Core
parent9f2d4ee53e9040925aa56ea5a04a374578562d02 (diff)
parentc130a496f28010d6bc59bb9c45013f69fbdd3dc3 (diff)
Merge pull request #1121 from FioraAeterna/fixfsel
JIT: fix fsel/ps_sel implementations for NaN input
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/Core/PowerPC/Jit64/Jit_FloatingPoint.cpp12
-rw-r--r--Source/Core/Core/PowerPC/Jit64/Jit_Paired.cpp12
2 files changed, 13 insertions, 11 deletions
diff --git a/Source/Core/Core/PowerPC/Jit64/Jit_FloatingPoint.cpp b/Source/Core/Core/PowerPC/Jit64/Jit_FloatingPoint.cpp
index 434b661ce1..fe321d4e63 100644
--- a/Source/Core/Core/PowerPC/Jit64/Jit_FloatingPoint.cpp
+++ b/Source/Core/Core/PowerPC/Jit64/Jit_FloatingPoint.cpp
@@ -212,10 +212,12 @@ void Jit64::fselx(UGeckoInstruction inst)
int c = inst.FC;
fpr.Lock(a, b, c, d);
- MOVSD(XMM0, fpr.R(a));
- PXOR(XMM1, R(XMM1));
- // XMM0 = XMM0 < 0 ? all 1s : all 0s
- CMPSD(XMM0, R(XMM1), LT);
+ MOVSD(XMM1, fpr.R(a));
+ PXOR(XMM0, R(XMM0));
+ // This condition is very tricky; there's only one right way to handle both the case of
+ // negative/positive zero and NaN properly.
+ // (a >= -0.0 ? c : b) transforms into (0 > a ? b : c), hence the NLE.
+ CMPSD(XMM0, R(XMM1), NLE);
if (cpu_info.bSSE4_1)
{
MOVSD(XMM1, fpr.R(c));
@@ -228,7 +230,7 @@ void Jit64::fselx(UGeckoInstruction inst)
PANDN(XMM1, fpr.R(c));
POR(XMM1, R(XMM0));
}
- fpr.BindToRegister(d, false);
+ fpr.BindToRegister(d, true);
MOVSD(fpr.RX(d), R(XMM1));
fpr.UnlockAll();
}
diff --git a/Source/Core/Core/PowerPC/Jit64/Jit_Paired.cpp b/Source/Core/Core/PowerPC/Jit64/Jit_Paired.cpp
index b246968424..7df0302e64 100644
--- a/Source/Core/Core/PowerPC/Jit64/Jit_Paired.cpp
+++ b/Source/Core/Core/PowerPC/Jit64/Jit_Paired.cpp
@@ -43,17 +43,17 @@ void Jit64::ps_sel(UGeckoInstruction inst)
if (cpu_info.bSSE4_1)
{
- MOVAPD(XMM0, fpr.R(a));
- PXOR(XMM1, R(XMM1));
- CMPPD(XMM0, R(XMM1), LT); // XMM0 = XMM0 < 0 ? all 1s : all 0s
+ MOVAPD(XMM1, fpr.R(a));
+ PXOR(XMM0, R(XMM0));
+ CMPPD(XMM0, R(XMM1), NLE);
MOVAPD(XMM1, fpr.R(c));
BLENDVPD(XMM1, fpr.R(b));
}
else
{
- MOVAPD(XMM1, fpr.R(a));
- PXOR(XMM0, R(XMM0));
- CMPPD(XMM1, R(XMM0), LT); // XMM0 = XMM0 < 0 ? all 1s : all 0s
+ MOVAPD(XMM0, fpr.R(a));
+ PXOR(XMM1, R(XMM1));
+ CMPPD(XMM1, R(XMM0), NLE);
MOVAPD(XMM0, R(XMM1));
PAND(XMM1, fpr.R(b));
PANDN(XMM0, fpr.R(c));