Jit: Move negx to ConstantPropagation

This commit is contained in:
JosJuice 2023-08-24 14:45:39 +02:00
parent 92a5a46b2c
commit 4c8995fae5
4 changed files with 30 additions and 23 deletions

View File

@ -2283,15 +2283,8 @@ void Jit64::negx(UGeckoInstruction inst)
int a = inst.RA;
int d = inst.RD;
if (gpr.IsImm(a))
{
gpr.SetImmediate32(d, ~(gpr.Imm32(a)) + 1);
if (inst.OE)
GenerateConstantOverflow(gpr.Imm32(d) == 0x80000000);
}
else
{
RCOpArg Ra = gpr.Use(a, RCMode::Read);
RCOpArg Ra = gpr.UseNoImm(a, RCMode::Read);
RCX64Reg Rd = gpr.Bind(d, RCMode::Write);
RegCache::Realize(Ra, Rd);

View File

@ -534,19 +534,10 @@ void JitArm64::negx(UGeckoInstruction inst)
FALLBACK_IF(inst.OE);
if (gpr.IsImm(a))
{
gpr.SetImmediate(d, ~((u32)gpr.GetImm(a)) + 1);
if (inst.Rc)
ComputeRC0(gpr.GetImm(d));
}
else
{
gpr.BindToRegister(d, d == a);
SUB(gpr.R(d), ARM64Reg::WSP, gpr.R(a));
if (inst.Rc)
ComputeRC0(gpr.R(d));
}
}
void JitArm64::cmp(UGeckoInstruction inst)

View File

@ -94,9 +94,31 @@ ConstantPropagationResult ConstantPropagation::EvaluateTable31(UGeckoInstruction
}
else
{
switch (inst.SUBOP10)
{
case 104: // negx
case 616: // negox
// input a -> output d
return EvaluateTable31Negx(inst, flags);
default:
// input s -> output a
return EvaluateTable31S(inst);
}
}
}
ConstantPropagationResult ConstantPropagation::EvaluateTable31Negx(UGeckoInstruction inst,
u64 flags) const
{
if (!HasGPR(inst.RA))
return {};
const s64 out = -s64(s32(GetGPR(inst.RA)));
ConstantPropagationResult result(inst.RD, u32(out), inst.Rc);
if (flags & FL_SET_OE)
result.overflow = (out != s64(s32(out)));
return result;
}
ConstantPropagationResult ConstantPropagation::EvaluateTable31S(UGeckoInstruction inst) const

View File

@ -81,6 +81,7 @@ private:
ConstantPropagationResult EvaluateBitwiseImm(UGeckoInstruction inst,
u32 (*do_op)(u32, u32)) const;
ConstantPropagationResult EvaluateTable31(UGeckoInstruction inst, u64 flags) const;
ConstantPropagationResult EvaluateTable31Negx(UGeckoInstruction inst, u64 flags) const;
ConstantPropagationResult EvaluateTable31S(UGeckoInstruction inst) const;
ConstantPropagationResult EvaluateTable31AB(UGeckoInstruction inst, u64 flags) const;
ConstantPropagationResult EvaluateTable31SB(UGeckoInstruction inst) const;