Merge pull request #1563 from SChernykh/dev

Optimized CFROUND
This commit is contained in:
xmrig 2020-02-22 01:45:52 +07:00 committed by GitHub
commit f9e653ea9f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 35 additions and 1 deletions

View file

@ -1118,6 +1118,29 @@ namespace randomx {
codePos = pos;
}
void JitCompilerX86::h_CFROUND_BMI2(const Instruction& instr) {
uint8_t* const p = code;
int pos = codePos;
const uint64_t src = instr.src;
const uint64_t rotate = (static_cast<int>(instr.getImm32() & 63) - 2) & 63;
*(uint64_t*)(p + pos) = 0xC0F0FBC3C4ULL | (src << 32) | (rotate << 40);
if (vm_flags & RANDOMX_FLAG_AMD) {
*(uint64_t*)(p + pos + 6) = 0x742024443B0CE083ULL;
*(uint8_t*)(p + pos + 14) = 8;
*(uint64_t*)(p + pos + 15) = 0x202444890414AE0FULL;
pos += 23;
}
else {
*(uint64_t*)(p + pos + 6) = 0x0414AE0F0CE083ULL;
pos += 13;
}
codePos = pos;
}
void JitCompilerX86::h_CBRANCH(const Instruction& instr) {
uint8_t* const p = code;
int pos = codePos;

View file

@ -147,6 +147,7 @@ namespace randomx {
void h_FSQRT_R(const Instruction&);
void h_CBRANCH(const Instruction&);
void h_CFROUND(const Instruction&);
void h_CFROUND_BMI2(const Instruction&);
void h_ISTORE(const Instruction&);
void h_NOP(const Instruction&);
};

View file

@ -279,7 +279,17 @@ void RandomX_ConfigurationBase::Apply()
INST_HANDLE(FDIV_M, FMUL_R);
INST_HANDLE(FSQRT_R, FDIV_M);
INST_HANDLE(CBRANCH, FSQRT_R);
INST_HANDLE(CFROUND, CBRANCH);
#if defined(_M_X64) || defined(__x86_64__)
if (xmrig::Cpu::info()->hasBMI2()) {
INST_HANDLE2(CFROUND, CFROUND_BMI2, CBRANCH);
}
else
#endif
{
INST_HANDLE(CFROUND, CBRANCH);
}
INST_HANDLE(ISTORE, CFROUND);
INST_HANDLE(NOP, ISTORE);
#undef INST_HANDLE