From c692ccdd6de6bc7473100172935cb1d9b9ac5a14 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 1 May 2018 08:19:21 -0400 Subject: [PATCH] emit_x64_vector: Vectorize fallback path of EmitVectorMaxS8() --- src/backend_x64/emit_x64_vector.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/backend_x64/emit_x64_vector.cpp b/src/backend_x64/emit_x64_vector.cpp index 9906ea57..0e9a546a 100644 --- a/src/backend_x64/emit_x64_vector.cpp +++ b/src/backend_x64/emit_x64_vector.cpp @@ -1001,9 +1001,19 @@ void EmitX64::EmitVectorMaxS8(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.UseScratchXmm(args[1]); + + const Xbyak::Xmm tmp_b = ctx.reg_alloc.ScratchXmm(); + code.movdqa(tmp_b, b); + + code.pcmpgtb(tmp_b, a); + code.pand(b, tmp_b); + code.pandn(tmp_b, a); + code.por(tmp_b, b); + + ctx.reg_alloc.DefineValue(inst, tmp_b); } void EmitX64::EmitVectorMaxS16(EmitContext& ctx, IR::Inst* inst) {