From 7797bc2fb29eedbcf81e97f062da5686f4d171d6 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 15 Jul 2018 22:06:29 -0400 Subject: [PATCH] emit_x64_vector: Use non-scratch Use* variants of registers within EmitVectorUnsignedAbsoluteDifference() In some cases, a register isn't modified, depending on the branch taken, so we can signify this by using the non-scratch variants in certain cases. --- src/backend_x64/emit_x64_vector.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/backend_x64/emit_x64_vector.cpp b/src/backend_x64/emit_x64_vector.cpp index f561e985..56a14d8e 100644 --- a/src/backend_x64/emit_x64_vector.cpp +++ b/src/backend_x64/emit_x64_vector.cpp @@ -2188,29 +2188,41 @@ static void EmitVectorUnsignedAbsoluteDifference(size_t esize, EmitContext& ctx, auto args = ctx.reg_alloc.GetArgumentInfo(inst); const Xbyak::Xmm temp = ctx.reg_alloc.ScratchXmm(); - const Xbyak::Xmm x = ctx.reg_alloc.UseScratchXmm(args[0]); - const Xbyak::Xmm y = ctx.reg_alloc.UseScratchXmm(args[1]); switch (esize) { - case 8: + case 8: { + const Xbyak::Xmm x = ctx.reg_alloc.UseXmm(args[0]); + const Xbyak::Xmm y = ctx.reg_alloc.UseScratchXmm(args[1]); + code.movdqa(temp, x); code.psubusb(temp, y); code.psubusb(y, x); code.por(temp, y); break; - case 16: + } + case 16: { + const Xbyak::Xmm x = ctx.reg_alloc.UseXmm(args[0]); + const Xbyak::Xmm y = ctx.reg_alloc.UseScratchXmm(args[1]); + code.movdqa(temp, x); code.psubusw(temp, y); code.psubusw(y, x); code.por(temp, y); break; + } case 32: if (code.DoesCpuSupport(Xbyak::util::Cpu::tSSE41)) { + const Xbyak::Xmm x = ctx.reg_alloc.UseScratchXmm(args[0]); + const Xbyak::Xmm y = ctx.reg_alloc.UseXmm(args[1]); + code.movdqa(temp, x); code.pminud(x, y); code.pmaxud(temp, y); code.psubd(temp, x); } else { + const Xbyak::Xmm x = ctx.reg_alloc.UseScratchXmm(args[0]); + const Xbyak::Xmm y = ctx.reg_alloc.UseScratchXmm(args[1]); + code.movdqa(temp, code.MConst(xword, 0x8000000080000000, 0x8000000080000000)); code.pxor(x, temp); code.pxor(y, temp);