Jit_Integer: rlwimix: Flatten logic

This commit is contained in:
MerryMage 2020-12-28 12:53:24 +00:00
parent 0ef1fcdeb9
commit c20bb81071
1 changed files with 49 additions and 51 deletions

View File

@ -1667,7 +1667,10 @@ void Jit64::rlwimix(UGeckoInstruction inst)
} }
else else
{ {
const bool left_shift = mask == 0U - (1U << inst.SH);
const bool right_shift = mask == (1U << inst.SH) - 1;
bool needs_test = false; bool needs_test = false;
if (mask == 0 || (a == s && inst.SH == 0)) if (mask == 0 || (a == s && inst.SH == 0))
{ {
needs_test = true; needs_test = true;
@ -1687,63 +1690,58 @@ void Jit64::rlwimix(UGeckoInstruction inst)
AndWithMask(Ra, ~mask); AndWithMask(Ra, ~mask);
OR(32, Ra, Imm32(Common::RotateLeft(gpr.Imm32(s), inst.SH) & mask)); OR(32, Ra, Imm32(Common::RotateLeft(gpr.Imm32(s), inst.SH) & mask));
} }
else if (inst.SH) else if (inst.SH && gpr.IsImm(a))
{ {
bool isLeftShift = mask == 0U - (1U << inst.SH); u32 maskA = gpr.Imm32(a) & ~mask;
bool isRightShift = mask == (1U << inst.SH) - 1;
if (gpr.IsImm(a)) RCOpArg Rs = gpr.Use(s, RCMode::Read);
RCX64Reg Ra = gpr.Bind(a, RCMode::Write);
RegCache::Realize(Rs, Ra);
if (left_shift)
{ {
u32 maskA = gpr.Imm32(a) & ~mask; MOV(32, Ra, Rs);
SHL(32, Ra, Imm8(inst.SH));
RCOpArg Rs = gpr.Use(s, RCMode::Read); }
RCX64Reg Ra = gpr.Bind(a, RCMode::Write); else if (right_shift)
RegCache::Realize(Rs, Ra); {
MOV(32, Ra, Rs);
if (isLeftShift) SHR(32, Ra, Imm8(32 - inst.SH));
{
MOV(32, Ra, Rs);
SHL(32, Ra, Imm8(inst.SH));
}
else if (isRightShift)
{
MOV(32, Ra, Rs);
SHR(32, Ra, Imm8(32 - inst.SH));
}
else
{
RotateLeft(32, Ra, Rs, inst.SH);
AndWithMask(Ra, mask);
}
OR(32, Ra, Imm32(maskA));
} }
else else
{ {
// TODO: common cases of this might be faster with pinsrb or abuse of AH RotateLeft(32, Ra, Rs, inst.SH);
RCOpArg Rs = gpr.Use(s, RCMode::Read); AndWithMask(Ra, mask);
RCX64Reg Ra = gpr.Bind(a, RCMode::ReadWrite); }
RegCache::Realize(Rs, Ra); OR(32, Ra, Imm32(maskA));
}
else if (inst.SH)
{
// TODO: common cases of this might be faster with pinsrb or abuse of AH
RCOpArg Rs = gpr.Use(s, RCMode::Read);
RCX64Reg Ra = gpr.Bind(a, RCMode::ReadWrite);
RegCache::Realize(Rs, Ra);
if (isLeftShift) if (left_shift)
{ {
MOV(32, R(RSCRATCH), Rs); MOV(32, R(RSCRATCH), Rs);
SHL(32, R(RSCRATCH), Imm8(inst.SH)); SHL(32, R(RSCRATCH), Imm8(inst.SH));
AndWithMask(Ra, ~mask); AndWithMask(Ra, ~mask);
OR(32, Ra, R(RSCRATCH)); OR(32, Ra, R(RSCRATCH));
} }
else if (isRightShift) else if (right_shift)
{ {
MOV(32, R(RSCRATCH), Rs); MOV(32, R(RSCRATCH), Rs);
SHR(32, R(RSCRATCH), Imm8(32 - inst.SH)); SHR(32, R(RSCRATCH), Imm8(32 - inst.SH));
AndWithMask(Ra, ~mask); AndWithMask(Ra, ~mask);
OR(32, Ra, R(RSCRATCH)); OR(32, Ra, R(RSCRATCH));
} }
else else
{ {
RotateLeft(32, RSCRATCH, Rs, inst.SH); RotateLeft(32, RSCRATCH, Rs, inst.SH);
XOR(32, R(RSCRATCH), Ra); XOR(32, R(RSCRATCH), Ra);
AndWithMask(RSCRATCH, mask); AndWithMask(RSCRATCH, mask);
XOR(32, Ra, R(RSCRATCH)); XOR(32, Ra, R(RSCRATCH));
}
} }
} }
else else