Merge pull request #9675 from JosJuice/jit64-div-80000000
Jit64: Fix UB/infinite loop when compiling division by 0x80000000
This commit is contained in:
commit
51bf2dca21
|
@ -1480,9 +1480,9 @@ void Jit64::divwx(UGeckoInstruction inst)
|
||||||
if (inst.OE)
|
if (inst.OE)
|
||||||
GenerateConstantOverflow(false);
|
GenerateConstantOverflow(false);
|
||||||
}
|
}
|
||||||
else if (MathUtil::IsPow2(divisor) || MathUtil::IsPow2(-divisor))
|
else if (MathUtil::IsPow2(divisor) || MathUtil::IsPow2(-static_cast<s64>(divisor)))
|
||||||
{
|
{
|
||||||
u32 abs_val = std::abs(divisor);
|
const u32 abs_val = static_cast<u32>(std::abs(static_cast<s64>(divisor)));
|
||||||
|
|
||||||
X64Reg tmp = RSCRATCH;
|
X64Reg tmp = RSCRATCH;
|
||||||
if (Ra.IsSimpleReg() && Ra.GetSimpleReg() != Rd)
|
if (Ra.IsSimpleReg() && Ra.GetSimpleReg() != Rd)
|
||||||
|
|
|
@ -16,7 +16,7 @@ struct Magic
|
||||||
|
|
||||||
// Calculate the constants required to optimize a signed 32-bit integer division.
|
// Calculate the constants required to optimize a signed 32-bit integer division.
|
||||||
// Taken from The PowerPC Compiler Writer's Guide and LLVM.
|
// Taken from The PowerPC Compiler Writer's Guide and LLVM.
|
||||||
// Divisor must not be -1, 0, and 1.
|
// Divisor must not be -1, 0, 1 or INT_MIN.
|
||||||
Magic SignedDivisionConstants(s32 divisor);
|
Magic SignedDivisionConstants(s32 divisor);
|
||||||
|
|
||||||
} // namespace JitCommon
|
} // namespace JitCommon
|
||||||
|
|
Loading…
Reference in New Issue