diff --git a/src/xenia/cpu/backend/x64/x64_sequences.cc b/src/xenia/cpu/backend/x64/x64_sequences.cc index 34cef4f7d..07883ba00 100644 --- a/src/xenia/cpu/backend/x64/x64_sequences.cc +++ b/src/xenia/cpu/backend/x64/x64_sequences.cc @@ -317,31 +317,20 @@ struct CONVERT_I32_F64 struct CONVERT_I64_F64 : Sequence> { static void Emit(X64Emitter& e, const EmitArgType& i) { - // Copy src1. - e.movq(e.rcx, i.src1); + e.xor_(e.eax, e.eax); - // TODO(benvanik): saturation check? cvtt* (trunc?) + e.vcomisd(i.src1, e.GetXmmConstPtr(XmmConst::XMMZero)); if (i.instr->flags == ROUND_TO_ZERO) { e.vcvttsd2si(i.dest, i.src1); } else { e.vcvtsd2si(i.dest, i.src1); } - - // 0x8000000000000000 - e.mov(e.rax, 0x1); - e.shl(e.rax, 63); - - // Saturate positive overflow - // TODO(DrChat): Find a shorter equivalent sequence. - // if (result ind. && src1 >= 0) - // result = 0x7FFFFFFFFFFFFFFF; - e.cmp(e.rax, i.dest); - e.sete(e.al); - e.movzx(e.rax, e.al); - e.shr(e.rcx, 63); - e.xor_(e.rcx, 0x01); - e.and_(e.rax, e.rcx); - + // cf set if less than + e.setnc(e.cl); + e.cmp(i.dest, -1LL); + // if dest == 0x80000000 and not inp < 0 then dest = 0x7FFFFFFF + e.seto(e.al); + e.and_(e.al, e.cl); e.sub(i.dest, e.rax); } };