From 7c8fcaef26b829c1799a6b556e9182765f425013 Mon Sep 17 00:00:00 2001 From: MerryMage Date: Sun, 18 Nov 2018 10:03:13 +0000 Subject: [PATCH] emit_x64_vector_floating_point: AVX && DN implementation of EmitFPVectorMulX --- .../x64/emit_x64_vector_floating_point.cpp | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/backend/x64/emit_x64_vector_floating_point.cpp b/src/backend/x64/emit_x64_vector_floating_point.cpp index 12b92c4c..0cc3b0b5 100644 --- a/src/backend/x64/emit_x64_vector_floating_point.cpp +++ b/src/backend/x64/emit_x64_vector_floating_point.cpp @@ -362,7 +362,7 @@ void EmitThreeOpVectorOperation(BlockOfCode& code, EmitContext& ctx, IR::Inst* i template void EmitTwoOpFallback(BlockOfCode& code, EmitContext& ctx, IR::Inst* inst, Lambda lambda) { const auto fn = static_cast*>(lambda); - + auto args = ctx.reg_alloc.GetArgumentInfo(inst); const Xbyak::Xmm arg1 = ctx.reg_alloc.UseXmm(args[0]); const Xbyak::Xmm result = ctx.reg_alloc.ScratchXmm(); @@ -960,6 +960,26 @@ static void EmitFPVectorMulX(BlockOfCode& code, EmitContext& ctx, IR::Inst* inst auto args = ctx.reg_alloc.GetArgumentInfo(inst); + if (ctx.FPSCR_DN() && code.DoesCpuSupport(Xbyak::util::Cpu::tAVX)) { + const Xbyak::Xmm result = ctx.reg_alloc.UseScratchXmm(args[0]); + const Xbyak::Xmm operand = ctx.reg_alloc.UseXmm(args[1]); + const Xbyak::Xmm tmp = ctx.reg_alloc.ScratchXmm(); + const Xbyak::Xmm twos = ctx.reg_alloc.ScratchXmm(); + + FCODE(vcmpunordp)(xmm0, result, operand); + FCODE(vxorp)(twos, result, operand); + FCODE(mulp)(result, operand); + FCODE(andp)(twos, GetNegativeZeroVector(code)); + FCODE(vcmpunordp)(tmp, result, result); + FCODE(blendvp)(result, GetNaNVector(code)); + FCODE(orp)(twos, GetVectorOf(code)); + FCODE(andnp)(xmm0, tmp); + FCODE(blendvp)(result, twos); + + ctx.reg_alloc.DefineValue(inst, result); + return; + } + const Xbyak::Xmm result = ctx.reg_alloc.ScratchXmm(); const Xbyak::Xmm xmm_a = ctx.reg_alloc.UseXmm(args[0]); const Xbyak::Xmm xmm_b = ctx.reg_alloc.UseXmm(args[1]); @@ -1052,7 +1072,7 @@ void EmitX64::EmitFPVectorPairedAddLower64(EmitContext& ctx, IR::Inst* inst) { EmitThreeOpVectorOperation<64, PairedLowerIndexer>(code, ctx, inst, [&](Xbyak::Xmm result, Xbyak::Xmm xmm_b) { const Xbyak::Xmm zero = ctx.reg_alloc.ScratchXmm(); code.xorps(zero, zero); - code.punpcklqdq(result, xmm_b); + code.punpcklqdq(result, xmm_b); code.haddpd(result, zero); }); }