diff --git a/Source/Core/Core/PowerPC/Jit64/Jit_Integer.cpp b/Source/Core/Core/PowerPC/Jit64/Jit_Integer.cpp index 040444c7211..5f3b5e17992 100644 --- a/Source/Core/Core/PowerPC/Jit64/Jit_Integer.cpp +++ b/Source/Core/Core/PowerPC/Jit64/Jit_Integer.cpp @@ -2283,15 +2283,8 @@ void Jit64::negx(UGeckoInstruction inst) int a = inst.RA; int d = inst.RD; - if (gpr.IsImm(a)) { - gpr.SetImmediate32(d, ~(gpr.Imm32(a)) + 1); - if (inst.OE) - GenerateConstantOverflow(gpr.Imm32(d) == 0x80000000); - } - else - { - RCOpArg Ra = gpr.Use(a, RCMode::Read); + RCOpArg Ra = gpr.UseNoImm(a, RCMode::Read); RCX64Reg Rd = gpr.Bind(d, RCMode::Write); RegCache::Realize(Ra, Rd); diff --git a/Source/Core/Core/PowerPC/JitArm64/JitArm64_Integer.cpp b/Source/Core/Core/PowerPC/JitArm64/JitArm64_Integer.cpp index 1e080817a34..a0d13c6a267 100644 --- a/Source/Core/Core/PowerPC/JitArm64/JitArm64_Integer.cpp +++ b/Source/Core/Core/PowerPC/JitArm64/JitArm64_Integer.cpp @@ -534,19 +534,10 @@ void JitArm64::negx(UGeckoInstruction inst) FALLBACK_IF(inst.OE); - if (gpr.IsImm(a)) - { - gpr.SetImmediate(d, ~((u32)gpr.GetImm(a)) + 1); - if (inst.Rc) - ComputeRC0(gpr.GetImm(d)); - } - else - { - gpr.BindToRegister(d, d == a); - SUB(gpr.R(d), ARM64Reg::WSP, gpr.R(a)); - if (inst.Rc) - ComputeRC0(gpr.R(d)); - } + gpr.BindToRegister(d, d == a); + SUB(gpr.R(d), ARM64Reg::WSP, gpr.R(a)); + if (inst.Rc) + ComputeRC0(gpr.R(d)); } void JitArm64::cmp(UGeckoInstruction inst) diff --git a/Source/Core/Core/PowerPC/JitCommon/ConstantPropagation.cpp b/Source/Core/Core/PowerPC/JitCommon/ConstantPropagation.cpp index 630929efbcf..a79d8f00fa1 100644 --- a/Source/Core/Core/PowerPC/JitCommon/ConstantPropagation.cpp +++ b/Source/Core/Core/PowerPC/JitCommon/ConstantPropagation.cpp @@ -94,11 +94,33 @@ ConstantPropagationResult ConstantPropagation::EvaluateTable31(UGeckoInstruction } else { - // input s -> output a - return EvaluateTable31S(inst); + switch (inst.SUBOP10) + { + case 104: // negx + case 616: // negox + // input a -> output d + return EvaluateTable31Negx(inst, flags); + default: + // input s -> output a + return EvaluateTable31S(inst); + } } } +ConstantPropagationResult ConstantPropagation::EvaluateTable31Negx(UGeckoInstruction inst, + u64 flags) const +{ + if (!HasGPR(inst.RA)) + return {}; + + const s64 out = -s64(s32(GetGPR(inst.RA))); + + ConstantPropagationResult result(inst.RD, u32(out), inst.Rc); + if (flags & FL_SET_OE) + result.overflow = (out != s64(s32(out))); + return result; +} + ConstantPropagationResult ConstantPropagation::EvaluateTable31S(UGeckoInstruction inst) const { if (!HasGPR(inst.RS)) diff --git a/Source/Core/Core/PowerPC/JitCommon/ConstantPropagation.h b/Source/Core/Core/PowerPC/JitCommon/ConstantPropagation.h index 9dfc6e602e8..097932e1bbc 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 EvaluateTable31Negx(UGeckoInstruction inst, u64 flags) const; ConstantPropagationResult EvaluateTable31S(UGeckoInstruction inst) const; ConstantPropagationResult EvaluateTable31AB(UGeckoInstruction inst, u64 flags) const; ConstantPropagationResult EvaluateTable31SB(UGeckoInstruction inst) const;