From f1ebbcd7bc277afa0e0a635db7f9fe3511f581e3 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 8 Sep 2018 02:02:47 -0400 Subject: [PATCH] emit_x64_vector: Simplify "position == 0" case for EmitVectorExtract() In the event position is zero, we can just treat it as a NOP, given there's no need to move the data. --- src/backend/x64/emit_x64_vector.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/backend/x64/emit_x64_vector.cpp b/src/backend/x64/emit_x64_vector.cpp index 7069b7e5..6eec6fce 100644 --- a/src/backend/x64/emit_x64_vector.cpp +++ b/src/backend/x64/emit_x64_vector.cpp @@ -764,14 +764,17 @@ void EmitX64::EmitVectorExtract(EmitContext& ctx, IR::Inst* inst) { auto args = ctx.reg_alloc.GetArgumentInfo(inst); const Xbyak::Xmm xmm_a = ctx.reg_alloc.UseScratchXmm(args[0]); - const Xbyak::Xmm xmm_b = ctx.reg_alloc.UseScratchXmm(args[1]); const u8 position = args[2].GetImmediateU8(); ASSERT(position % 8 == 0); - code.psrldq(xmm_a, position / 8); - code.pslldq(xmm_b, (128 - position) / 8); - code.por(xmm_a, xmm_b); + if (position != 0) { + const Xbyak::Xmm xmm_b = ctx.reg_alloc.UseScratchXmm(args[1]); + + code.psrldq(xmm_a, position / 8); + code.pslldq(xmm_b, (128 - position) / 8); + code.por(xmm_a, xmm_b); + } ctx.reg_alloc.DefineValue(inst, xmm_a); }