From cda85a1da02596c61bf63e674da355b8c4ab275f Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 28 Apr 2018 20:04:07 -0400 Subject: [PATCH] emit_x64_vector: Vectorize fallback path in EmitVectorMinS32() --- 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 7a161d92..afa73542 100644 --- a/src/backend_x64/emit_x64_vector.cpp +++ b/src/backend_x64/emit_x64_vector.cpp @@ -1095,9 +1095,19 @@ void EmitX64::EmitVectorMinS32(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::min(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]); + + const Xbyak::Xmm tmp_b = ctx.reg_alloc.ScratchXmm(); + code.movdqa(tmp_b, b); + + code.pcmpgtd(tmp_b, a); + code.pand(a, tmp_b); + code.pandn(tmp_b, b); + code.por(a, tmp_b); + + ctx.reg_alloc.DefineValue(inst, a); } void EmitX64::EmitVectorMinS64(EmitContext& ctx, IR::Inst* inst) {