Jit: Move addix to ConstantPropagation

This commit is contained in:
JosJuice 2023-08-22 19:50:38 +02:00
parent 90c89ce533
commit 0b81bd8412
4 changed files with 30 additions and 31 deletions

View File

@ -260,12 +260,6 @@ void Jit64::regimmop(int d, int a, bool binary, u32 value, Operation doop,
if (a || binary || carry)
{
carry &= js.op->wantsCA;
if (gpr.IsImm(a) && !carry)
{
gpr.SetImmediate32(d, doop(gpr.Imm32(a), value));
}
else
{
RCOpArg Ra = gpr.Use(a, RCMode::Read);
RCX64Reg Rd = gpr.Bind(d, RCMode::Write);
RegCache::Realize(Ra, Rd);
@ -279,7 +273,6 @@ void Jit64::regimmop(int d, int a, bool binary, u32 value, Operation doop,
MOV(32, Rd, Ra);
(this->*op)(32, Rd, Imm32(value)); // m_GPR[d] = m_GPR[_inst.RA] + _inst.SIMM_16;
}
}
if (carry)
FinalizeCarry(CC_C);
}
@ -304,12 +297,8 @@ void Jit64::reg_imm(UGeckoInstruction inst)
switch (inst.OPCD)
{
case 14: // addi
// occasionally used as MOV - emulate, with immediate propagation
if (a != 0 && d != a && gpr.IsImm(a))
{
gpr.SetImmediate32(d, gpr.Imm32(a) + (u32)(s32)inst.SIMM_16);
}
else if (a != 0 && d != a && inst.SIMM_16 == 0)
// occasionally used as MOV
if (a != 0 && d != a && inst.SIMM_16 == 0)
{
RCOpArg Ra = gpr.Use(a, RCMode::Read);
RCX64Reg Rd = gpr.Bind(d, RCMode::Write);

View File

@ -216,19 +216,12 @@ void JitArm64::addix(UGeckoInstruction inst)
}
if (a)
{
if (gpr.IsImm(a))
{
gpr.SetImmediate(d, gpr.GetImm(a) + imm);
}
else
{
gpr.BindToRegister(d, d == a);
auto WA = gpr.GetScopedReg();
ADDI2R(gpr.R(d), gpr.R(a), imm, WA);
}
}
else
{
// a == 0, implies zero register

View File

@ -24,6 +24,9 @@ ConstantPropagationResult ConstantPropagation::EvaluateInstruction(UGeckoInstruc
{
switch (inst.OPCD)
{
case 14: // addi
case 15: // addis
return EvaluateAddImm(inst);
case 24: // ori
case 25: // oris
return EvaluateBitwiseImm(inst, BitOR);
@ -38,6 +41,19 @@ ConstantPropagationResult ConstantPropagation::EvaluateInstruction(UGeckoInstruc
}
}
ConstantPropagationResult ConstantPropagation::EvaluateAddImm(UGeckoInstruction inst) const
{
const s32 immediate = inst.OPCD & 1 ? inst.SIMM_16 << 16 : inst.SIMM_16;
if (inst.RA == 0)
return ConstantPropagationResult(inst.RD, immediate);
if (!HasGPR(inst.RA))
return {};
return ConstantPropagationResult(inst.RD, m_gpr_values[inst.RA] + immediate);
}
ConstantPropagationResult ConstantPropagation::EvaluateBitwiseImm(UGeckoInstruction inst,
u32 (*do_op)(u32, u32)) const
{

View File

@ -77,6 +77,7 @@ public:
void Clear() { m_gpr_values_known = BitSet32{}; }
private:
ConstantPropagationResult EvaluateAddImm(UGeckoInstruction inst) const;
ConstantPropagationResult EvaluateBitwiseImm(UGeckoInstruction inst,
u32 (*do_op)(u32, u32)) const;