mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-12-16 04:09:39 +00:00
Jit: Move subfic to ConstantPropagation
This commit is contained in:
parent
204a8fbd53
commit
c7d8a0b276
@ -1042,14 +1042,6 @@ void Jit64::subfic(UGeckoInstruction inst)
|
|||||||
JITDISABLE(bJITIntegerOff);
|
JITDISABLE(bJITIntegerOff);
|
||||||
int a = inst.RA, d = inst.RD, imm = inst.SIMM_16;
|
int a = inst.RA, d = inst.RD, imm = inst.SIMM_16;
|
||||||
|
|
||||||
if (gpr.IsImm(a))
|
|
||||||
{
|
|
||||||
u32 i = imm, j = gpr.Imm32(a);
|
|
||||||
gpr.SetImmediate32(d, i - j);
|
|
||||||
FinalizeCarry(j == 0 || (i > j - 1));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
RCOpArg Ra = gpr.Use(a, RCMode::Read);
|
RCOpArg Ra = gpr.Use(a, RCMode::Read);
|
||||||
RCX64Reg Rd = gpr.Bind(d, RCMode::Write);
|
RCX64Reg Rd = gpr.Bind(d, RCMode::Write);
|
||||||
RegCache::Realize(Ra, Rd);
|
RegCache::Realize(Ra, Rd);
|
||||||
|
|||||||
@ -1381,44 +1381,34 @@ void JitArm64::subfic(UGeckoInstruction inst)
|
|||||||
int a = inst.RA, d = inst.RD;
|
int a = inst.RA, d = inst.RD;
|
||||||
s32 imm = inst.SIMM_16;
|
s32 imm = inst.SIMM_16;
|
||||||
|
|
||||||
if (gpr.IsImm(a))
|
const bool will_read = d == a;
|
||||||
{
|
gpr.BindToRegister(d, will_read);
|
||||||
u32 a_imm = gpr.GetImm(a);
|
ARM64Reg RD = gpr.R(d);
|
||||||
|
|
||||||
gpr.SetImmediate(d, imm - a_imm);
|
if (imm == -1)
|
||||||
ComputeCarry(a_imm == 0 || Interpreter::Helper_Carry(imm, 0u - a_imm));
|
{
|
||||||
|
// d = -1 - a = ~a
|
||||||
|
MVN(RD, gpr.R(a));
|
||||||
|
// CA is always set in this case
|
||||||
|
ComputeCarry(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const bool will_read = d == a;
|
const bool is_zero = imm == 0;
|
||||||
gpr.BindToRegister(d, will_read);
|
|
||||||
ARM64Reg RD = gpr.R(d);
|
|
||||||
|
|
||||||
if (imm == -1)
|
// d = imm - a
|
||||||
{
|
{
|
||||||
// d = -1 - a = ~a
|
Arm64GPRCache::ScopedARM64Reg WA(ARM64Reg::WZR);
|
||||||
MVN(RD, gpr.R(a));
|
if (!is_zero)
|
||||||
// CA is always set in this case
|
|
||||||
ComputeCarry(true);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
const bool is_zero = imm == 0;
|
|
||||||
|
|
||||||
// d = imm - a
|
|
||||||
{
|
{
|
||||||
Arm64GPRCache::ScopedARM64Reg WA(ARM64Reg::WZR);
|
WA = will_read ? gpr.GetScopedReg() : Arm64GPRCache::ScopedARM64Reg(RD);
|
||||||
if (!is_zero)
|
MOVI2R(WA, imm);
|
||||||
{
|
|
||||||
WA = will_read ? gpr.GetScopedReg() : Arm64GPRCache::ScopedARM64Reg(RD);
|
|
||||||
MOVI2R(WA, imm);
|
|
||||||
}
|
|
||||||
|
|
||||||
CARRY_IF_NEEDED(SUB, SUBS, RD, WA, gpr.R(a));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ComputeCarry();
|
CARRY_IF_NEEDED(SUB, SUBS, RD, WA, gpr.R(a));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ComputeCarry();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -33,6 +33,8 @@ ConstantPropagationResult ConstantPropagation::EvaluateInstruction(UGeckoInstruc
|
|||||||
{
|
{
|
||||||
case 7: // mulli
|
case 7: // mulli
|
||||||
return EvaluateMulImm(inst);
|
return EvaluateMulImm(inst);
|
||||||
|
case 8: // subfic
|
||||||
|
return EvaluateSubImmCarry(inst);
|
||||||
case 12: // addic
|
case 12: // addic
|
||||||
case 13: // addic.
|
case 13: // addic.
|
||||||
return EvaluateAddImmCarry(inst);
|
return EvaluateAddImmCarry(inst);
|
||||||
@ -73,6 +75,19 @@ ConstantPropagationResult ConstantPropagation::EvaluateMulImm(UGeckoInstruction
|
|||||||
return ConstantPropagationResult(inst.RD, m_gpr_values[inst.RA] * inst.SIMM_16);
|
return ConstantPropagationResult(inst.RD, m_gpr_values[inst.RA] * inst.SIMM_16);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ConstantPropagationResult ConstantPropagation::EvaluateSubImmCarry(UGeckoInstruction inst) const
|
||||||
|
{
|
||||||
|
if (!HasGPR(inst.RA))
|
||||||
|
return {};
|
||||||
|
|
||||||
|
const u32 a = GetGPR(inst.RA);
|
||||||
|
const u32 imm = s32(inst.SIMM_16);
|
||||||
|
|
||||||
|
ConstantPropagationResult result(inst.RD, imm - a);
|
||||||
|
result.carry = imm >= a;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
ConstantPropagationResult ConstantPropagation::EvaluateAddImm(UGeckoInstruction inst) const
|
ConstantPropagationResult ConstantPropagation::EvaluateAddImm(UGeckoInstruction inst) const
|
||||||
{
|
{
|
||||||
const s32 immediate = inst.OPCD & 1 ? inst.SIMM_16 << 16 : inst.SIMM_16;
|
const s32 immediate = inst.OPCD & 1 ? inst.SIMM_16 << 16 : inst.SIMM_16;
|
||||||
|
|||||||
@ -78,6 +78,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
ConstantPropagationResult EvaluateMulImm(UGeckoInstruction inst) const;
|
ConstantPropagationResult EvaluateMulImm(UGeckoInstruction inst) const;
|
||||||
|
ConstantPropagationResult EvaluateSubImmCarry(UGeckoInstruction inst) const;
|
||||||
ConstantPropagationResult EvaluateAddImm(UGeckoInstruction inst) const;
|
ConstantPropagationResult EvaluateAddImm(UGeckoInstruction inst) const;
|
||||||
ConstantPropagationResult EvaluateAddImmCarry(UGeckoInstruction inst) const;
|
ConstantPropagationResult EvaluateAddImmCarry(UGeckoInstruction inst) const;
|
||||||
ConstantPropagationResult EvaluateRlwinmxRlwnmx(UGeckoInstruction inst, u32 shift) const;
|
ConstantPropagationResult EvaluateRlwinmxRlwnmx(UGeckoInstruction inst, u32 shift) const;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user