From 78922a077213b95c437e296fc4c72f597a6124b5 Mon Sep 17 00:00:00 2001 From: SChernykh Date: Sat, 23 Jan 2021 22:28:50 +0100 Subject: [PATCH] RandomX JIT x86: remove unnecessary instructions Adopted from https://github.com/tevador/RandomX/pull/201 --- src/crypto/randomx/jit_compiler_x86.cpp | 8 +++----- src/crypto/randomx/jit_compiler_x86_static.S | 2 -- src/crypto/randomx/jit_compiler_x86_static.asm | 2 -- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/crypto/randomx/jit_compiler_x86.cpp b/src/crypto/randomx/jit_compiler_x86.cpp index 8c3145b2..5685b080 100644 --- a/src/crypto/randomx/jit_compiler_x86.cpp +++ b/src/crypto/randomx/jit_compiler_x86.cpp @@ -417,12 +417,10 @@ namespace randomx { void JitCompilerX86::generateProgramPrologue(Program& prog, ProgramConfiguration& pcfg) { codePos = ADDR(randomx_program_prologue_first_load) - ADDR(randomx_program_prologue); - code[codePos + 2] = 0xc0 + pcfg.readReg0; - code[codePos + 5] = 0xc0 + pcfg.readReg1; - *(uint32_t*)(code + codePos + 10) = RandomX_CurrentConfig.ScratchpadL3Mask64_Calculated; - *(uint32_t*)(code + codePos + 20) = RandomX_CurrentConfig.ScratchpadL3Mask64_Calculated; + *(uint32_t*)(code + codePos + 4) = RandomX_CurrentConfig.ScratchpadL3Mask64_Calculated; + *(uint32_t*)(code + codePos + 14) = RandomX_CurrentConfig.ScratchpadL3Mask64_Calculated; if (hasAVX) { - uint32_t* p = (uint32_t*)(code + codePos + 67); + uint32_t* p = (uint32_t*)(code + codePos + 61); *p = (*p & 0xFF000000U) | 0x0077F8C5U; } diff --git a/src/crypto/randomx/jit_compiler_x86_static.S b/src/crypto/randomx/jit_compiler_x86_static.S index e2177147..2ead26e9 100644 --- a/src/crypto/randomx/jit_compiler_x86_static.S +++ b/src/crypto/randomx/jit_compiler_x86_static.S @@ -93,8 +93,6 @@ DECL(randomx_program_prologue): movapd xmm15, xmmword ptr [scaleMask+rip] DECL(randomx_program_prologue_first_load): - xor rax, r8 - xor rax, r8 mov rdx, rax and eax, RANDOMX_SCRATCHPAD_MASK ror rdx, 32 diff --git a/src/crypto/randomx/jit_compiler_x86_static.asm b/src/crypto/randomx/jit_compiler_x86_static.asm index 6e90cbf3..2c5d1bbe 100644 --- a/src/crypto/randomx/jit_compiler_x86_static.asm +++ b/src/crypto/randomx/jit_compiler_x86_static.asm @@ -81,8 +81,6 @@ randomx_program_prologue PROC randomx_program_prologue ENDP randomx_program_prologue_first_load PROC - xor rax, r8 - xor rax, r8 mov rdx, rax and eax, RANDOMX_SCRATCHPAD_MASK ror rdx, 32