From af471d0a84b671c887d092ca86b4dd34e709c98a Mon Sep 17 00:00:00 2001 From: Fiora Date: Mon, 8 Sep 2014 21:36:50 -0700 Subject: [PATCH] JIT: optimize andi(s)_rc We usually don't need to do a sign-extend for the resulting flags. --- Source/Core/Core/PowerPC/Jit64/Jit.h | 2 +- Source/Core/Core/PowerPC/Jit64/Jit_Integer.cpp | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Source/Core/Core/PowerPC/Jit64/Jit.h b/Source/Core/Core/PowerPC/Jit64/Jit.h index 53a846237f..e006286ff4 100644 --- a/Source/Core/Core/PowerPC/Jit64/Jit.h +++ b/Source/Core/Core/PowerPC/Jit64/Jit.h @@ -103,7 +103,7 @@ public: void FinalizeCarryOverflow(bool oe, bool inv = false); void FinalizeCarry(Gen::CCFlags cond); 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. Gen::OpArg ExtractFromReg(int reg, int offset); diff --git a/Source/Core/Core/PowerPC/Jit64/Jit_Integer.cpp b/Source/Core/Core/PowerPC/Jit64/Jit_Integer.cpp index dbb6a5fbf1..57e9434f08 100644 --- a/Source/Core/Core/PowerPC/Jit64/Jit_Integer.cpp +++ b/Source/Core/Core/PowerPC/Jit64/Jit_Integer.cpp @@ -116,17 +116,21 @@ void Jit64::FinalizeCarryOverflow(bool oe, bool inv) 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()) { MOV(64, PPCSTATE(cr_val[0]), Imm32((s32)arg.offset)); } - else + else if (sign_extend) { MOVSX(64, 32, RSCRATCH, arg); MOV(64, PPCSTATE(cr_val[0]), R(RSCRATCH)); } + else + { + MOV(64, PPCSTATE(cr_val[0]), arg); + } } 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) FinalizeCarry(CC_C); if (Rc) - ComputeRC(gpr.R(d)); + ComputeRC(gpr.R(d), doop != And || (value & 0x80000000)); } else if (doop == Add) {