From 1a4156a4a09eeb047afe889d0dde02799c4c3c12 Mon Sep 17 00:00:00 2001 From: magumagu Date: Sun, 13 Apr 2014 20:25:56 -0700 Subject: [PATCH] JitIL: fix carry computation for srawi. The carry computation needs to be based on the input value, not the output of the shift. --- .../Core/PowerPC/JitILCommon/JitILBase_Integer.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Source/Core/Core/PowerPC/JitILCommon/JitILBase_Integer.cpp b/Source/Core/Core/PowerPC/JitILCommon/JitILBase_Integer.cpp index 441a3bc743..cf8bad0fce 100644 --- a/Source/Core/Core/PowerPC/JitILCommon/JitILBase_Integer.cpp +++ b/Source/Core/Core/PowerPC/JitILCommon/JitILBase_Integer.cpp @@ -503,16 +503,18 @@ void JitILBase::srawix(UGeckoInstruction inst) { INSTRUCTION_START JITDISABLE(bJITIntegerOff) - IREmitter::InstLoc val = ibuild.EmitLoadGReg(inst.RS), test; - val = ibuild.EmitSarl(val, ibuild.EmitIntConst(inst.SH)); - ibuild.EmitStoreGReg(val, inst.RA); + // Shift right by two + IREmitter::InstLoc input = ibuild.EmitLoadGReg(inst.RS); + IREmitter::InstLoc output = ibuild.EmitSarl(input, ibuild.EmitIntConst(inst.SH)); + ibuild.EmitStoreGReg(output, inst.RA); + // Check whether the input is negative and any bits got shifted out. unsigned int mask = -1u << inst.SH; - test = ibuild.EmitOr(val, ibuild.EmitIntConst(mask & 0x7FFFFFFF)); + IREmitter::InstLoc test = ibuild.EmitOr(input, ibuild.EmitIntConst(mask & 0x7FFFFFFF)); test = ibuild.EmitICmpUgt(test, ibuild.EmitIntConst(mask)); ibuild.EmitStoreCarry(test); if (inst.Rc) - ComputeRC(ibuild, val); + ComputeRC(ibuild, output); } // count leading zeroes