From 54de64f5bf23aaacd147b475f4228927f297a417 Mon Sep 17 00:00:00 2001 From: MerryMage Date: Sat, 27 Jan 2018 00:38:09 +0000 Subject: [PATCH] a64_emit_x64: bug: x64 sign-extends 32-bit immediates --- src/backend_x64/a64_emit_x64.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/backend_x64/a64_emit_x64.cpp b/src/backend_x64/a64_emit_x64.cpp index 4c53f0db..98c25cb8 100644 --- a/src/backend_x64/a64_emit_x64.cpp +++ b/src/backend_x64/a64_emit_x64.cpp @@ -261,8 +261,8 @@ void A64EmitX64::EmitA64SetQ(A64EmitContext& ctx, IR::Inst* inst) { void A64EmitX64::EmitA64SetSP(A64EmitContext& ctx, IR::Inst* inst) { auto args = ctx.reg_alloc.GetArgumentInfo(inst); auto addr = qword[r15 + offsetof(A64JitState, sp)]; - if (args[0].FitsInImmediateU32()) { - code->mov(addr, args[0].GetImmediateU32()); + if (args[0].FitsInImmediateS32()) { + code->mov(addr, args[0].GetImmediateS32()); } else if (args[0].IsInXmm()) { Xbyak::Xmm to_store = ctx.reg_alloc.UseXmm(args[0]); code->movq(addr, to_store); @@ -275,8 +275,8 @@ void A64EmitX64::EmitA64SetSP(A64EmitContext& ctx, IR::Inst* inst) { void A64EmitX64::EmitA64SetPC(A64EmitContext& ctx, IR::Inst* inst) { auto args = ctx.reg_alloc.GetArgumentInfo(inst); auto addr = qword[r15 + offsetof(A64JitState, pc)]; - if (args[0].FitsInImmediateU32()) { - code->mov(addr, args[0].GetImmediateU32()); + if (args[0].FitsInImmediateS32()) { + code->mov(addr, args[0].GetImmediateS32()); } else if (args[0].IsInXmm()) { Xbyak::Xmm to_store = ctx.reg_alloc.UseXmm(args[0]); code->movq(addr, to_store);