From 27a6d5f6ce560a1d00f798da9b1c3aa6d93f47b2 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 4 May 2018 12:25:57 -0400 Subject: [PATCH] emit_x64_vector: Use VPOPCNTB in EmitVectorPopulationCount() if AVX-512 BITALG is available --- src/backend_x64/emit_x64_vector.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/backend_x64/emit_x64_vector.cpp b/src/backend_x64/emit_x64_vector.cpp index 8e6b0034..23780db7 100644 --- a/src/backend_x64/emit_x64_vector.cpp +++ b/src/backend_x64/emit_x64_vector.cpp @@ -1613,6 +1613,16 @@ void EmitX64::EmitVectorPairedAdd64(EmitContext& ctx, IR::Inst* inst) { } void EmitX64::EmitVectorPopulationCount(EmitContext& ctx, IR::Inst* inst) { + if (code.DoesCpuSupport(Xbyak::util::Cpu::tAVX512_BITALG)) { + auto args = ctx.reg_alloc.GetArgumentInfo(inst); + const Xbyak::Xmm data = ctx.reg_alloc.UseScratchXmm(args[0]); + + code.vpopcntb(data, data); + + ctx.reg_alloc.DefineValue(inst, data); + return; + } + if (code.DoesCpuSupport(Xbyak::util::Cpu::tSSSE3)) { auto args = ctx.reg_alloc.GetArgumentInfo(inst);