From 14eb70d7e4ad7a61683ebd12a46cf178883b9709 Mon Sep 17 00:00:00 2001 From: Sebastian Valle Date: Sun, 27 Nov 2016 18:25:50 -0500 Subject: [PATCH] VFP: Fixed the VCVT behavior when converting from unsigned 32-bit values. (#51) Use a 64-bit register to hold the values so that we don't end up interpreting them as signed values. --- src/backend_x64/emit_x64.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/backend_x64/emit_x64.cpp b/src/backend_x64/emit_x64.cpp index 3f24a08b..6052a12b 100644 --- a/src/backend_x64/emit_x64.cpp +++ b/src/backend_x64/emit_x64.cpp @@ -2009,9 +2009,10 @@ void EmitX64::EmitFPU32ToSingle(IR::Block& block, IR::Inst* inst) { Xbyak::Xmm from = reg_alloc.UseXmm(a); Xbyak::Xmm to = reg_alloc.DefXmm(inst); - Xbyak::Reg32 gpr_scratch = reg_alloc.ScratchGpr().cvt32(); + // Use a 64-bit register to ensure we don't end up treating the input as signed + Xbyak::Reg64 gpr_scratch = reg_alloc.ScratchGpr(); - code->movd(gpr_scratch, from); + code->movq(gpr_scratch, from); code->cvtsi2ss(to, gpr_scratch); } @@ -2035,9 +2036,10 @@ void EmitX64::EmitFPU32ToDouble(IR::Block& block, IR::Inst* inst) { Xbyak::Xmm from = reg_alloc.UseXmm(a); Xbyak::Xmm to = reg_alloc.DefXmm(inst); - Xbyak::Reg32 gpr_scratch = reg_alloc.ScratchGpr().cvt32(); + // Use a 64-bit register to ensure we don't end up treating the input as signed + Xbyak::Reg64 gpr_scratch = reg_alloc.ScratchGpr(); - code->movd(gpr_scratch, from); + code->movq(gpr_scratch, from); code->cvtsi2sd(to, gpr_scratch); }