Generalize constant folding for rlwinm.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1640 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
magumagu9 2008-12-23 13:16:52 +00:00
parent 6dd9fa75f8
commit 590adfce53
1 changed files with 8 additions and 12 deletions

View File

@ -671,19 +671,15 @@
INSTRUCTION_START;
int a = inst.RA;
int s = inst.RS;
if (gpr.R(a).IsImm() || gpr.R(s).IsImm())
if (gpr.R(s).IsImm() && !inst.Rc)
{
if (gpr.R(s).IsImm())
{
if (gpr.R(s).offset == 0 && !inst.Rc) {
// This is pretty common for some reason
gpr.LoadToX64(a, false);
XOR(32, gpr.R(a), gpr.R(a));
return;
}
// This might also be worth doing.
}
Default(inst);
unsigned mask = Helper_Mask(inst.MB, inst.ME);
unsigned result = gpr.R(s).offset;
if (inst.SH != 0)
result = (result << inst.SH) |
(result >> (32 - inst.SH));
result &= mask;
gpr.SetImmediate32(a, result);
return;
}