From 0f067b73301e6e5127b51032e7896cf5d7bd6638 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 3 May 2018 12:46:13 -0400 Subject: [PATCH] emit_x64_vector: Emit VPABSQ in EmitVectorAbs() for the 64-bit case if AVX-512VL is available --- src/backend_x64/emit_x64_vector.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/backend_x64/emit_x64_vector.cpp b/src/backend_x64/emit_x64_vector.cpp index c7acfca1..099cc1a1 100644 --- a/src/backend_x64/emit_x64_vector.cpp +++ b/src/backend_x64/emit_x64_vector.cpp @@ -293,15 +293,18 @@ static void EmitVectorAbs(size_t esize, EmitContext& ctx, IR::Inst* inst, BlockO code.psubd(data, temp); } break; - case 64: { - const Xbyak::Xmm temp = ctx.reg_alloc.ScratchXmm(); - code.pshufd(temp, data, 0b11110101); - code.psrad(temp, 31); - code.pxor(data, temp); - code.psubq(data, temp); + case 64: + if (code.DoesCpuSupport(Xbyak::util::Cpu::tAVX512VL)) { + code.vpabsq(data, data); + } else { + const Xbyak::Xmm temp = ctx.reg_alloc.ScratchXmm(); + code.pshufd(temp, data, 0b11110101); + code.psrad(temp, 31); + code.pxor(data, temp); + code.psubq(data, temp); + } break; } - } ctx.reg_alloc.DefineValue(inst, data); }