Jit: Move srawx to ConstantPropagation

This commit is contained in:
JosJuice 2024-09-01 11:28:37 +02:00
parent 4985a01c16
commit 7e4dce4d19
3 changed files with 23 additions and 49 deletions

View File

@ -2338,22 +2338,7 @@ void Jit64::srawx(UGeckoInstruction inst)
int b = inst.RB;
int s = inst.RS;
if (gpr.IsImm(b, s))
{
s32 i = gpr.SImm32(s), amount = gpr.SImm32(b);
if (amount & 0x20)
{
gpr.SetImmediate32(a, i & 0x80000000 ? 0xFFFFFFFF : 0);
FinalizeCarry(i & 0x80000000 ? true : false);
}
else
{
amount &= 0x1F;
gpr.SetImmediate32(a, i >> amount);
FinalizeCarry(amount != 0 && i < 0 && (u32(i) << (32 - amount)));
}
}
else if (gpr.IsImm(b))
if (gpr.IsImm(b))
{
u32 amount = gpr.Imm32(b);
RCX64Reg Ra = gpr.Bind(a, RCMode::Write);
@ -2389,11 +2374,6 @@ void Jit64::srawx(UGeckoInstruction inst)
FinalizeCarry(CC_NZ);
}
}
else if (gpr.IsImm(s) && gpr.Imm32(s) == 0)
{
gpr.SetImmediate32(a, 0);
FinalizeCarry(false);
}
else if (cpu_info.bBMI2)
{
RCX64Reg Ra = gpr.Bind(a, RCMode::Write);

View File

@ -1667,34 +1667,7 @@ void JitArm64::srawx(UGeckoInstruction inst)
int a = inst.RA, b = inst.RB, s = inst.RS;
if (gpr.IsImm(b) && gpr.IsImm(s))
{
s32 i = gpr.GetImm(s), amount = gpr.GetImm(b);
if (amount & 0x20)
{
gpr.SetImmediate(a, i & 0x80000000 ? 0xFFFFFFFF : 0);
ComputeCarry(i & 0x80000000 ? true : false);
}
else
{
amount &= 0x1F;
gpr.SetImmediate(a, i >> amount);
ComputeCarry(amount != 0 && i < 0 && (u32(i) << (32 - amount)));
}
if (inst.Rc)
ComputeRC0(gpr.GetImm(a));
return;
}
else if (gpr.IsImm(s, 0))
{
gpr.SetImmediate(a, 0);
ComputeCarry(false);
if (inst.Rc)
ComputeRC0(0);
return;
}
else if (gpr.IsImm(b))
if (gpr.IsImm(b))
{
int amount = gpr.GetImm(b);

View File

@ -401,6 +401,15 @@ ConstantPropagationResult ConstantPropagation::EvaluateTable31SB(UGeckoInstructi
case 536: // srwx
a = u32(u64(s) >> b);
break;
case 792: // srawx
{
const u64 temp = (s64(s32(s)) << 32) >> b;
a = u32(temp >> 32);
ConstantPropagationResult result(inst.RA, a, inst.Rc);
result.carry = (temp & a) != 0;
return result;
}
default:
return {};
}
@ -457,6 +466,18 @@ ConstantPropagation::EvaluateTable31SBOneRegisterKnown(UGeckoInstruction inst, u
else
return {};
break;
case 792: // srawx
if (!known_reg_is_b && value == 0)
{
ConstantPropagationResult result(inst.RA, 0, inst.Rc);
result.carry = false;
return result;
}
else
{
return {};
}
break;
default:
return {};
}