From bdb5b0eae25f6682c7021a32f1c07f9b1ab7bf6f Mon Sep 17 00:00:00 2001 From: Ben Vanik Date: Thu, 3 Oct 2013 20:18:56 -0700 Subject: [PATCH] Fixing alignment of xmm load/store. --- src/xenia/cpu/x64/x64_emitter.cc | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/xenia/cpu/x64/x64_emitter.cc b/src/xenia/cpu/x64/x64_emitter.cc index 22a64ea0c..5eb9c1b76 100644 --- a/src/xenia/cpu/x64/x64_emitter.cc +++ b/src/xenia/cpu/x64/x64_emitter.cc @@ -1886,7 +1886,7 @@ XmmVar X64Emitter::ReadMemoryXmm( } // Rebase off of memory base pointer. - GpVar real_address = TouchMemoryAddress(cia, addr); + GpVar real_address = TouchMemoryAddress(cia, aligned_addr); XmmVar value(c.newXmmVar()); c.movaps(value, xmmword_ptr(real_address)); @@ -1955,9 +1955,19 @@ void X64Emitter::WriteMemoryXmm( X86Compiler& c = compiler_; // Align memory address. + GpVar aligned_addr(c.newGpVar()); + c.mov(aligned_addr, addr); + switch (alignment) { + case 4: + c.and_(aligned_addr, imm(~0xF)); + break; + default: + XEASSERTALWAYS(); + break; + } // Rebase off of memory base pointer. - GpVar real_address = TouchMemoryAddress(cia, addr); + GpVar real_address = TouchMemoryAddress(cia, aligned_addr); // Byte swap. // TODO(benvanik): clone value before modifying it?