Use XOR when loading a zero immediate

This commit is contained in:
Tillmann Karras 2016-08-06 21:04:13 +01:00
parent 55204a80d0
commit 9264e2e04c

View file

@ -485,7 +485,11 @@ std::tuple<HostLoc, bool> 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;
}