From 450762790537d4f548e12bb59d3e37becadd82b4 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 31 Aug 2018 11:43:08 -0400 Subject: [PATCH] emit_x64_vector: Provide AVX path for EmitVectorMinU64() --- src/backend/x64/emit_x64_vector.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/backend/x64/emit_x64_vector.cpp b/src/backend/x64/emit_x64_vector.cpp index 2f8645c1..989abd91 100644 --- a/src/backend/x64/emit_x64_vector.cpp +++ b/src/backend/x64/emit_x64_vector.cpp @@ -1503,6 +1503,23 @@ void EmitX64::EmitVectorMinU64(EmitContext& ctx, IR::Inst* inst) { return; } + if (code.DoesCpuSupport(Xbyak::util::Cpu::tAVX)) { + auto args = ctx.reg_alloc.GetArgumentInfo(inst); + + const Xbyak::Xmm x = ctx.reg_alloc.UseXmm(args[0]); + const Xbyak::Xmm y = ctx.reg_alloc.UseScratchXmm(args[1]); + const Xbyak::Xmm tmp = ctx.reg_alloc.ScratchXmm(); + + code.vmovdqa(xmm0, code.MConst(xword, 0x8000000000000000, 0x8000000000000000)); + code.vpsubq(tmp, y, xmm0); + code.vpsubq(xmm0, x, xmm0); + code.vpcmpgtq(xmm0, tmp, xmm0); + code.pblendvb(y, x); + + ctx.reg_alloc.DefineValue(inst, y); + return; + } + EmitTwoArgumentFallback(code, ctx, inst, [](VectorArray& result, const VectorArray& a, const VectorArray& b){ std::transform(a.begin(), a.end(), b.begin(), result.begin(), [](auto x, auto y) { return std::min(x, y); }); });