From 6414736a8d239fd9ff720fe713b57dce62a64f56 Mon Sep 17 00:00:00 2001 From: MerryMage Date: Fri, 2 Feb 2018 21:07:00 +0000 Subject: [PATCH] emit_x64_vector: bug: VectorGetElement8 returning incorrect values for non-SSE4.1 This bug wasn't discovered earlier because we previously only used index == 0. --- src/backend_x64/emit_x64_vector.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/backend_x64/emit_x64_vector.cpp b/src/backend_x64/emit_x64_vector.cpp index f5fe6503..455d0296 100644 --- a/src/backend_x64/emit_x64_vector.cpp +++ b/src/backend_x64/emit_x64_vector.cpp @@ -41,7 +41,10 @@ void EmitX64::EmitVectorGetElement8(EmitContext& ctx, IR::Inst* inst) { ctx.reg_alloc.DefineValue(inst, dest); } else { Xbyak::Reg32 dest = ctx.reg_alloc.ScratchGpr().cvt32(); - code->pextrw(dest, source, index); + code->pextrw(dest, source, index / 2); + if (index % 2 == 1) { + code->shr(dest, 8); + } ctx.reg_alloc.DefineValue(inst, dest); } }