From 9264e2e04c32f3daee5417276e133026f6f0cbc7 Mon Sep 17 00:00:00 2001 From: Tillmann Karras Date: Sat, 6 Aug 2016 21:04:13 +0100 Subject: [PATCH] Use XOR when loading a zero immediate --- src/backend_x64/reg_alloc.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/backend_x64/reg_alloc.cpp b/src/backend_x64/reg_alloc.cpp index f9469480..78ce97a4 100644 --- a/src/backend_x64/reg_alloc.cpp +++ b/src/backend_x64/reg_alloc.cpp @@ -485,7 +485,11 @@ std::tuple RegAlloc::UseHostLoc(IR::Inst* use_inst, HostLocList d Gen::X64Reg RegAlloc::LoadImmediateIntoRegister(IR::Value imm, Gen::X64Reg reg) { ASSERT_MSG(imm.IsImmediate(), "imm is not an immediate"); - code->MOV(32, Gen::R(reg), ImmediateToOpArg(imm)); + Gen::OpArg op_arg = ImmediateToOpArg(imm); + if (op_arg.GetImmValue() == 0) + code->XOR(32, Gen::R(reg), Gen::R(reg)); + else + code->MOV(32, Gen::R(reg), op_arg); return reg; }