From 6a4f12d7852594564039bf5ac6a53c49da61df4e Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 22 May 2018 12:32:20 -0400 Subject: [PATCH] JitArm64: Correct negative overflow handling for divw --- .../Core/PowerPC/JitArm64/JitArm64_Integer.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/Source/Core/Core/PowerPC/JitArm64/JitArm64_Integer.cpp b/Source/Core/Core/PowerPC/JitArm64/JitArm64_Integer.cpp index a620e4b9ad..c1fa56a4a1 100644 --- a/Source/Core/Core/PowerPC/JitArm64/JitArm64_Integer.cpp +++ b/Source/Core/Core/PowerPC/JitArm64/JitArm64_Integer.cpp @@ -1164,17 +1164,17 @@ void JitArm64::divwx(UGeckoInstruction inst) { s32 imm_a = gpr.GetImm(a); s32 imm_b = gpr.GetImm(b); - s32 imm_d; - if (imm_b == 0 || ((u32)imm_a == 0x80000000 && imm_b == -1)) + u32 imm_d; + if (imm_b == 0 || (static_cast(imm_a) == 0x80000000 && imm_b == -1)) { - if (((u32)imm_a & 0x80000000) && imm_b == 0) - imm_d = -1; + if (imm_a < 0) + imm_d = 0xFFFFFFFF; else imm_d = 0; } else { - imm_d = (u32)(imm_a / imm_b); + imm_d = static_cast(imm_a / imm_b); } gpr.SetImmediate(d, imm_d); @@ -1217,9 +1217,7 @@ void JitArm64::divwx(UGeckoInstruction inst) SetJumpTarget(slow1); SetJumpTarget(slow2); - CMP(RB, 0); - CCMP(RA, 0, 0, CC_EQ); - CSETM(RD, CC_LT); + ASR(RD, RA, 31); SetJumpTarget(done);