Merge pull request #631 from Doom2fan/asmjit

Fix the code for MODF_RK in the JIT compiler.
This commit is contained in:
Magnus Norddahl 2018-11-15 00:07:55 +01:00 committed by GitHub
commit 8bdebd917c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 13 deletions

View File

@ -757,12 +757,17 @@ void JitCompiler::EmitMODF_RR()
void JitCompiler::EmitMODF_RK() void JitCompiler::EmitMODF_RK()
{ {
auto label = EmitThrowExceptionLabel(X_DIVISION_BY_ZERO); if (konstf[C] == 0.)
cc.ptest(regF[C], regF[C]); {
cc.je(label); EmitThrowException(X_DIVISION_BY_ZERO);
}
else
{
auto tmpPtr = newTempIntPtr();
cc.mov(tmpPtr, asmjit::imm_ptr(&konstf[C]));
auto tmp = newTempXmmSd(); auto tmp = newTempXmmSd();
cc.movsd(tmp, asmjit::x86::ptr(ToMemAddress(&konstf[C]))); cc.movsd(tmp, asmjit::x86::qword_ptr(tmpPtr));
auto result = newResultXmmSd(); auto result = newResultXmmSd();
auto call = CreateCall<double, double, double>([](double a, double b) -> double { auto call = CreateCall<double, double, double>([](double a, double b) -> double {
@ -772,6 +777,7 @@ void JitCompiler::EmitMODF_RK()
call->setArg(0, regF[B]); call->setArg(0, regF[B]);
call->setArg(1, tmp); call->setArg(1, tmp);
cc.movsd(regF[A], result); cc.movsd(regF[A], result);
}
} }
void JitCompiler::EmitMODF_KR() void JitCompiler::EmitMODF_KR()