From be8ddf12aa767604a162e6db89c334f9742b4aaf Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Fri, 15 Feb 2013 21:49:20 -0800 Subject: [PATCH] Don't go out of bounds applying vfpu swizzle. --- Core/MIPS/MIPSIntVFPU.cpp | 5 +++++ Core/MIPS/x86/CompVFPU.cpp | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/Core/MIPS/MIPSIntVFPU.cpp b/Core/MIPS/MIPSIntVFPU.cpp index ac012d8730..9237beeef4 100644 --- a/Core/MIPS/MIPSIntVFPU.cpp +++ b/Core/MIPS/MIPSIntVFPU.cpp @@ -110,6 +110,11 @@ void ApplyPrefixST(float *v, u32 data, VectorSize size) if (!constants) { + // Prefix may say "z, z, z, z" but if this is a pair, we force to x. + // TODO: But some ops seem to use const 0 instead? + if (regnum >= n) + regnum = 0; + v[i] = origV[regnum]; if (abs) v[i] = fabs(v[i]); diff --git a/Core/MIPS/x86/CompVFPU.cpp b/Core/MIPS/x86/CompVFPU.cpp index e693afbba1..2ea60ad844 100644 --- a/Core/MIPS/x86/CompVFPU.cpp +++ b/Core/MIPS/x86/CompVFPU.cpp @@ -87,6 +87,7 @@ void Jit::ApplyPrefixST(u8 *vregs, u32 prefix, VectorSize sz) { for (int i = 0; i < n; i++) { + // TODO: This needs to be the original values, not the original regs. (e.g. [-x, |x|, x]) origV[i] = vregs[i]; } @@ -98,6 +99,11 @@ void Jit::ApplyPrefixST(u8 *vregs, u32 prefix, VectorSize sz) { int constants = (prefix >> (12+i)) & 1; if (!constants) { + // Prefix may say "z, z, z, z" but if this is a pair, we force to x. + // TODO: But some ops seem to use const 0 instead? + if (regnum > n) { + regnum = 0; + } vregs[i] = origV[regnum]; if (abs) { ANDPS(fpr.VX(vregs[i]), M((void *)&noSignMask));