From 5bb19426b35abd62185bc03195e886be0e29ad71 Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Thu, 23 Oct 2014 15:21:02 +0000 Subject: [PATCH] Optimizes instructions in ARMv7's JIT inside of the arith function. For instructions where the second immediate value fits within an instruction encoding, just encode it directly in to the instruction. --- .../Core/PowerPC/JitArm32/JitArm_Integer.cpp | 54 ++++++++++++++----- 1 file changed, 40 insertions(+), 14 deletions(-) diff --git a/Source/Core/Core/PowerPC/JitArm32/JitArm_Integer.cpp b/Source/Core/Core/PowerPC/JitArm32/JitArm_Integer.cpp index de78e8f6d6..533615a880 100644 --- a/Source/Core/Core/PowerPC/JitArm32/JitArm_Integer.cpp +++ b/Source/Core/Core/PowerPC/JitArm32/JitArm_Integer.cpp @@ -253,7 +253,7 @@ void JitArm::arith(UGeckoInstruction inst) Imm[0] = gpr.GetImm(s); } isImm[1] = true; - Imm[1] = inst.UIMM << (shiftedImm ? 16 : 0); + Imm[1] = inst.UIMM; break; case 27: // xoris shiftedImm = true; @@ -354,7 +354,7 @@ void JitArm::arith(UGeckoInstruction inst) break; case 24: case 25: - gpr.SetImmediate(a, Or(Imm[0], Imm[1])); + gpr.SetImmediate(a, Or(Imm[0], Imm[1] << (shiftedImm ? 16 : 0))); dest = a; break; case 26: @@ -459,12 +459,20 @@ void JitArm::arith(UGeckoInstruction inst) case 13: { gpr.BindToRegister(d, d == a); - ARMReg rA = gpr.GetReg(); RD = gpr.R(d); RA = gpr.R(a); - MOVI2R(rA, Imm[1]); - ADDS(RD, RA, rA); - gpr.Unlock(rA); + + if (Imm[1] < 256) + { + ADDS(RD, RA, Imm[1]); + } + else + { + ARMReg rA = gpr.GetReg(); + MOVI2R(rA, Imm[1]); + ADDS(RD, RA, rA); + gpr.Unlock(rA); + } } break; case 14: @@ -472,12 +480,20 @@ void JitArm::arith(UGeckoInstruction inst) if (!isImm[0]) { gpr.BindToRegister(d, d == a); - ARMReg rA = gpr.GetReg(); RD = gpr.R(d); RA = gpr.R(a); - MOVI2R(rA, Imm[1]); - ADD(RD, RA, rA); - gpr.Unlock(rA); + + if (Imm[1] < 256) + { + ADD(RD, RA, Imm[1]); + } + else + { + ARMReg rA = gpr.GetReg(); + MOVI2R(rA, Imm[1]); + ADD(RD, RA, rA); + gpr.Unlock(rA); + } } else { @@ -489,12 +505,22 @@ void JitArm::arith(UGeckoInstruction inst) { dest = a; gpr.BindToRegister(a, s == a); - ARMReg rA = gpr.GetReg(); RS = gpr.R(s); RA = gpr.R(a); - MOVI2R(rA, Imm[1]); - ORR(RA, RS, rA); - gpr.Unlock(rA); + + if (Imm[1] < 256) + { + // Rotation of encoding 8 is the same as << 16 + Operand2 imm(Imm[1], shiftedImm ? 8 : 0); + ORR(RA, RS, imm); + } + else + { + ARMReg rA = gpr.GetReg(); + MOVI2R(rA, Imm[1] << (shiftedImm ? 16 : 0)); + ORR(RA, RS, rA); + gpr.Unlock(rA); + } } break; case 26: