From af28e89a134bb4f65cb2f8e7ecada8ec0be2ac90 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 27 Apr 2018 13:36:03 -0400 Subject: [PATCH] emit_x64_vector: Vectorize fallback path in EmitVectorMaxU16() --- src/backend_x64/emit_x64_vector.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/backend_x64/emit_x64_vector.cpp b/src/backend_x64/emit_x64_vector.cpp index 184f080d..68d7d7b4 100644 --- a/src/backend_x64/emit_x64_vector.cpp +++ b/src/backend_x64/emit_x64_vector.cpp @@ -1000,9 +1000,14 @@ void EmitX64::EmitVectorMaxU16(EmitContext& ctx, IR::Inst* inst) { return; } - EmitTwoArgumentFallback(code, ctx, inst, [](std::array& result, const std::array& a, const std::array& b){ - std::transform(a.begin(), a.end(), b.begin(), result.begin(), [](auto x, auto y) { return std::max(x, y); }); - }); + auto args = ctx.reg_alloc.GetArgumentInfo(inst); + const Xbyak::Xmm a = ctx.reg_alloc.UseScratchXmm(args[0]); + const Xbyak::Xmm b = ctx.reg_alloc.UseXmm(args[1]); + + code.psubusw(a, b); + code.paddw(a, b); + + ctx.reg_alloc.DefineValue(inst, a); } void EmitX64::EmitVectorMaxU32(EmitContext& ctx, IR::Inst* inst) {