From 8fb90c0cf1086a8603627b7dd6d9a7221e92d529 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 31 Aug 2018 11:58:48 -0400 Subject: [PATCH] emit_x64_vector: Provide AVX path for EmitVectorMaxS64() --- src/backend/x64/emit_x64_vector.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/backend/x64/emit_x64_vector.cpp b/src/backend/x64/emit_x64_vector.cpp index 0fece599..c0e24ec4 100644 --- a/src/backend/x64/emit_x64_vector.cpp +++ b/src/backend/x64/emit_x64_vector.cpp @@ -1282,6 +1282,19 @@ void EmitX64::EmitVectorMaxS64(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.UseScratchXmm(args[0]); + const Xbyak::Xmm y = ctx.reg_alloc.UseXmm(args[1]); + + code.vpcmpgtq(xmm0, y, x); + code.pblendvb(x, y); + + ctx.reg_alloc.DefineValue(inst, x); + 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::max(x, y); }); });