JIT: optimize andi(s)_rc

We usually don't need to do a sign-extend for the resulting flags.
This commit is contained in:
Fiora 2014-09-08 21:36:50 -07:00
parent 74f8a48ee6
commit af471d0a84
2 changed files with 8 additions and 4 deletions

View File

@ -103,7 +103,7 @@ public:
void FinalizeCarryOverflow(bool oe, bool inv = false); void FinalizeCarryOverflow(bool oe, bool inv = false);
void FinalizeCarry(Gen::CCFlags cond); void FinalizeCarry(Gen::CCFlags cond);
void FinalizeCarry(bool ca); void FinalizeCarry(bool ca);
void ComputeRC(const Gen::OpArg & arg); void ComputeRC(const Gen::OpArg & arg, bool sign_extend = true);
// Use to extract bytes from a register using the regcache. offset is in bytes. // Use to extract bytes from a register using the regcache. offset is in bytes.
Gen::OpArg ExtractFromReg(int reg, int offset); Gen::OpArg ExtractFromReg(int reg, int offset);

View File

@ -116,17 +116,21 @@ void Jit64::FinalizeCarryOverflow(bool oe, bool inv)
FinalizeCarry(inv ? CC_NC : CC_C); FinalizeCarry(inv ? CC_NC : CC_C);
} }
void Jit64::ComputeRC(const Gen::OpArg & arg) void Jit64::ComputeRC(const Gen::OpArg & arg, bool sign_extend)
{ {
if (arg.IsImm()) if (arg.IsImm())
{ {
MOV(64, PPCSTATE(cr_val[0]), Imm32((s32)arg.offset)); MOV(64, PPCSTATE(cr_val[0]), Imm32((s32)arg.offset));
} }
else else if (sign_extend)
{ {
MOVSX(64, 32, RSCRATCH, arg); MOVSX(64, 32, RSCRATCH, arg);
MOV(64, PPCSTATE(cr_val[0]), R(RSCRATCH)); MOV(64, PPCSTATE(cr_val[0]), R(RSCRATCH));
} }
else
{
MOV(64, PPCSTATE(cr_val[0]), arg);
}
} }
OpArg Jit64::ExtractFromReg(int reg, int offset) OpArg Jit64::ExtractFromReg(int reg, int offset)
@ -206,7 +210,7 @@ void Jit64::regimmop(int d, int a, bool binary, u32 value, Operation doop, void
if (carry) if (carry)
FinalizeCarry(CC_C); FinalizeCarry(CC_C);
if (Rc) if (Rc)
ComputeRC(gpr.R(d)); ComputeRC(gpr.R(d), doop != And || (value & 0x80000000));
} }
else if (doop == Add) else if (doop == Add)
{ {