summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorJosJuice <josjuice@gmail.com>2023-08-24 14:45:39 +0200
committerJosJuice <josjuice@gmail.com>2025-11-16 09:50:31 +0100
commit4c8995fae565357979e40576d7ece73b264afecd (patch)
tree41bf231b1ac8fff222d8a28fd132f25c23caf862 /Source
parent92a5a46b2c6ac8849b22cb931d5e37ecce036503 (diff)
Jit: Move negx to ConstantPropagation
Diffstat (limited to 'Source')
-rw-r--r--Source/Core/Core/PowerPC/Jit64/Jit_Integer.cpp9
-rw-r--r--Source/Core/Core/PowerPC/JitArm64/JitArm64_Integer.cpp17
-rw-r--r--Source/Core/Core/PowerPC/JitCommon/ConstantPropagation.cpp26
-rw-r--r--Source/Core/Core/PowerPC/JitCommon/ConstantPropagation.h1
4 files changed, 30 insertions, 23 deletions
diff --git a/Source/Core/Core/PowerPC/Jit64/Jit_Integer.cpp b/Source/Core/Core/PowerPC/Jit64/Jit_Integer.cpp
index 040444c721..5f3b5e1799 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 1e080817a3..a0d13c6a26 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 630929efbc..a79d8f00fa 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 9dfc6e602e..097932e1bb 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;