- use the immediate versions for loading integer constants when possible.

This commit is contained in:
Christoph Oelckers 2016-12-02 00:54:40 +01:00
parent 77192fa9dd
commit 719be058e5

View file

@ -2304,14 +2304,29 @@ ExpEmit FxAssign::Emit(VMFunctionBuilder *build)
ExpEmit pointer = Base->Emit(build);
Address = pointer;
ExpEmit result = Right->Emit(build);
ExpEmit result;
bool intconst = false;
int intconstval;
if (Right->isConstant() && Right->ValueType->GetRegType() == REGT_INT)
{
intconst = true;
intconstval = static_cast<FxConstant*>(Right)->GetValue().GetInt();
result.Konst = true;
result.RegType = REGT_INT;
}
else
{
result = Right->Emit(build);
}
assert(result.RegType <= REGT_TYPE);
if (pointer.Target)
{
if (result.Konst)
{
build->Emit(loadops[result.RegType], pointer.RegNum, result.RegNum);
if (intconst) build->EmitLoadInt(pointer.RegNum, intconstval);
else build->Emit(loadops[result.RegType], pointer.RegNum, result.RegNum);
}
else
{
@ -2323,7 +2338,8 @@ ExpEmit FxAssign::Emit(VMFunctionBuilder *build)
if (result.Konst)
{
ExpEmit temp(build, result.RegType);
build->Emit(loadops[result.RegType], temp.RegNum, result.RegNum);
if (intconst) build->EmitLoadInt(temp.RegNum, intconstval);
else build->Emit(loadops[result.RegType], temp.RegNum, result.RegNum);
result.Free(build);
result = temp;
}