From bf6aa780a74706c2b6d1c344dff8de40a8f79f0a Mon Sep 17 00:00:00 2001 From: Fei Peng Date: Mon, 12 Feb 2018 13:51:32 -0800 Subject: [PATCH] Fix SSE4.1 encoding --- src/jit/emitxarch.cpp | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/src/jit/emitxarch.cpp b/src/jit/emitxarch.cpp index 6d7a2a2..3555a0c 100644 --- a/src/jit/emitxarch.cpp +++ b/src/jit/emitxarch.cpp @@ -12072,21 +12072,35 @@ size_t emitter::emitOutputInstr(insGroup* ig, instrDesc* id, BYTE** dp) case IF_RWR_ARD: case IF_RRW_ARD: case IF_RWR_RRD_ARD: - code = insCodeRM(ins); - code = AddVexPrefixIfNeeded(ins, code, size); - regcode = (insEncodeReg345(ins, id->idReg1(), size, &code) << 8); - dst = emitOutputAM(dst, id, code | regcode); - sz = emitSizeOfInsDsc(id); + code = insCodeRM(ins); + if (Is4ByteSSE4OrAVXInstruction(ins)) + { + dst = emitOutputAM(dst, id, code); + } + else + { + code = AddVexPrefixIfNeeded(ins, code, size); + regcode = (insEncodeReg345(ins, id->idReg1(), size, &code) << 8); + dst = emitOutputAM(dst, id, code | regcode); + } + sz = emitSizeOfInsDsc(id); break; case IF_RWR_RRD_ARD_CNS: { emitGetInsAmdCns(id, &cnsVal); - code = insCodeRM(ins); - code = AddVexPrefixIfNeeded(ins, code, size); - regcode = (insEncodeReg345(ins, id->idReg1(), size, &code) << 8); - dst = emitOutputAM(dst, id, code | regcode, &cnsVal); - sz = emitSizeOfInsDsc(id); + code = insCodeRM(ins); + if (Is4ByteSSE4OrAVXInstruction(ins)) + { + dst = emitOutputAM(dst, id, code, &cnsVal); + } + else + { + code = AddVexPrefixIfNeeded(ins, code, size); + regcode = (insEncodeReg345(ins, id->idReg1(), size, &code) << 8); + dst = emitOutputAM(dst, id, code | regcode, &cnsVal); + } + sz = emitSizeOfInsDsc(id); break; } -- 2.7.4