diff --git a/Source/Core/Core/PowerPC/Jit64/Jit_Integer.cpp b/Source/Core/Core/PowerPC/Jit64/Jit_Integer.cpp index 1b5674f65b9..91e879fd69d 100644 --- a/Source/Core/Core/PowerPC/Jit64/Jit_Integer.cpp +++ b/Source/Core/Core/PowerPC/Jit64/Jit_Integer.cpp @@ -1026,13 +1026,8 @@ void Jit64::extsXx(UGeckoInstruction inst) int a = inst.RA, s = inst.RS; int size = inst.SUBOP10 == 922 ? 16 : 8; - if (gpr.IsImm(s)) { - gpr.SetImmediate32(a, (u32)(s32)(size == 16 ? (s16)gpr.Imm32(s) : (s8)gpr.Imm32(s))); - } - else - { - RCOpArg Rs = gpr.Use(s, RCMode::Read); + RCOpArg Rs = gpr.UseNoImm(s, RCMode::Read); RCX64Reg Ra = gpr.Bind(a, RCMode::Write); RegCache::Realize(Rs, Ra); MOVSX(32, size, Ra, Rs); diff --git a/Source/Core/Core/PowerPC/JitArm64/JitArm64_Integer.cpp b/Source/Core/Core/PowerPC/JitArm64/JitArm64_Integer.cpp index 6739de44399..bfab2217121 100644 --- a/Source/Core/Core/PowerPC/JitArm64/JitArm64_Integer.cpp +++ b/Source/Core/Core/PowerPC/JitArm64/JitArm64_Integer.cpp @@ -506,19 +506,10 @@ void JitArm64::extsXx(UGeckoInstruction inst) int a = inst.RA, s = inst.RS; int size = inst.SUBOP10 == 922 ? 16 : 8; - if (gpr.IsImm(s)) - { - gpr.SetImmediate(a, (u32)(s32)(size == 16 ? (s16)gpr.GetImm(s) : (s8)gpr.GetImm(s))); - if (inst.Rc) - ComputeRC0(gpr.GetImm(a)); - } - else - { - gpr.BindToRegister(a, a == s); - SBFM(gpr.R(a), gpr.R(s), 0, size - 1); - if (inst.Rc) - ComputeRC0(gpr.R(a)); - } + gpr.BindToRegister(a, a == s); + SBFM(gpr.R(a), gpr.R(s), 0, size - 1); + if (inst.Rc) + ComputeRC0(gpr.R(a)); } void JitArm64::cntlzwx(UGeckoInstruction inst) diff --git a/Source/Core/Core/PowerPC/JitCommon/ConstantPropagation.cpp b/Source/Core/Core/PowerPC/JitCommon/ConstantPropagation.cpp index 84a37efa16d..3aecc0f5316 100644 --- a/Source/Core/Core/PowerPC/JitCommon/ConstantPropagation.cpp +++ b/Source/Core/Core/PowerPC/JitCommon/ConstantPropagation.cpp @@ -77,18 +77,49 @@ ConstantPropagationResult ConstantPropagation::EvaluateBitwiseImm(UGeckoInstruct ConstantPropagationResult ConstantPropagation::EvaluateTable31(UGeckoInstruction inst, u64 flags) const { - if (flags & FL_OUT_D) + if (flags & FL_IN_B) { - // input a, b -> output d - return EvaluateTable31AB(inst, flags); + if (flags & FL_OUT_D) + { + // input a, b -> output d + return EvaluateTable31AB(inst, flags); + } + else + { + // input s, b -> output a + return EvaluateTable31SB(inst); + } } else { - // input s, b -> output a - return EvaluateTable31SB(inst); + // input s -> output a + return EvaluateTable31S(inst); } } +ConstantPropagationResult ConstantPropagation::EvaluateTable31S(UGeckoInstruction inst) const +{ + if (!HasGPR(inst.RS)) + return {}; + + u32 a; + const u32 s = GetGPR(inst.RS); + + switch (inst.SUBOP10) + { + case 922: // extshx + a = s32(s16(s)); + break; + case 954: // extsbx + a = s32(s8(s)); + break; + default: + return {}; + } + + return ConstantPropagationResult(inst.RA, a, inst.Rc); +} + ConstantPropagationResult ConstantPropagation::EvaluateTable31AB(UGeckoInstruction inst, u64 flags) const { diff --git a/Source/Core/Core/PowerPC/JitCommon/ConstantPropagation.h b/Source/Core/Core/PowerPC/JitCommon/ConstantPropagation.h index a7f5b27fd30..9dfc6e602e8 100644 --- a/Source/Core/Core/PowerPC/JitCommon/ConstantPropagation.h +++ b/Source/Core/Core/PowerPC/JitCommon/ConstantPropagation.h @@ -81,6 +81,7 @@ private: ConstantPropagationResult EvaluateBitwiseImm(UGeckoInstruction inst, u32 (*do_op)(u32, u32)) const; ConstantPropagationResult EvaluateTable31(UGeckoInstruction inst, u64 flags) const; + ConstantPropagationResult EvaluateTable31S(UGeckoInstruction inst) const; ConstantPropagationResult EvaluateTable31AB(UGeckoInstruction inst, u64 flags) const; ConstantPropagationResult EvaluateTable31SB(UGeckoInstruction inst) const; ConstantPropagationResult EvaluateTable31SBOneRegisterKnown(UGeckoInstruction inst, u32 value,