mirror of
https://git.suyu.dev/suyu/dynarmic.git
synced 2026-01-06 22:48:25 +01:00
emit_x64_floating_point: Correct error in s16 rounding in EmitFPToFixed
This commit is contained in:
parent
3ea49fc6d6
commit
2008fda88b
2 changed files with 23 additions and 6 deletions
|
|
@ -50,6 +50,7 @@ constexpr u64 f64_nan = 0x7ff8000000000000u;
|
|||
constexpr u64 f64_non_sign_mask = 0x7fffffffffffffffu;
|
||||
constexpr u64 f64_smallest_normal = 0x0010000000000000u;
|
||||
|
||||
constexpr u64 f64_min_s16 = 0xc0e0000000000000u; // -32768 as a double
|
||||
constexpr u64 f64_max_s16 = 0x40dfffc000000000u; // 32767 as a double
|
||||
constexpr u64 f64_min_u16 = 0x0000000000000000u; // 0 as a double
|
||||
constexpr u64 f64_max_u16 = 0x40efffe000000000u; // 65535 as a double
|
||||
|
|
@ -1275,12 +1276,8 @@ static void EmitFPToFixed(BlockOfCode& code, EmitContext& ctx, IR::Inst* inst) {
|
|||
}
|
||||
} else {
|
||||
code.minsd(src, code.MConst(xword, unsigned_ ? f64_max_u16 : f64_max_s16));
|
||||
if (unsigned_) {
|
||||
code.maxsd(src, code.MConst(xword, f64_min_u16));
|
||||
code.cvttsd2si(result, src); // 64 bit gpr
|
||||
} else {
|
||||
code.cvttsd2si(result.cvt32(), src);
|
||||
}
|
||||
code.maxsd(src, code.MConst(xword, unsigned_ ? f64_min_u16 : f64_min_s16));
|
||||
code.cvttsd2si(result, src); // 64 bit gpr
|
||||
}
|
||||
|
||||
ctx.reg_alloc.DefineValue(inst, result);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue