diff --git a/js/src/jit/mips64/CodeGenerator-mips64.cpp b/js/src/jit/mips64/CodeGenerator-mips64.cpp index 68943c93d4d5..1af0ea2d2f19 100644 --- a/js/src/jit/mips64/CodeGenerator-mips64.cpp +++ b/js/src/jit/mips64/CodeGenerator-mips64.cpp @@ -186,12 +186,16 @@ void CodeGenerator::visitCompareI64(LCompareI64* lir) { Register lhsReg = ToRegister64(lhs).reg; Register output = ToRegister(lir->output()); Register rhsReg; + ScratchRegisterScope scratch(masm); if (IsConstant(rhs)) { - rhsReg = ScratchRegister; + rhsReg = scratch; masm.ma_li(rhsReg, ImmWord(ToInt64(rhs))); - } else { + } else if (rhs.value().isGeneralReg()) { rhsReg = ToRegister64(rhs).reg; + } else { + rhsReg = scratch; + masm.loadPtr(ToAddress(rhs.value()), rhsReg); } bool isSigned = mir->compareType() == MCompare::Compare_Int64; @@ -208,12 +212,16 @@ void CodeGenerator::visitCompareI64AndBranch(LCompareI64AndBranch* lir) { const LInt64Allocation rhs = lir->getInt64Operand(LCompareI64::Rhs); Register lhsReg = ToRegister64(lhs).reg; Register rhsReg; + ScratchRegisterScope scratch(masm); if (IsConstant(rhs)) { - rhsReg = ScratchRegister; + rhsReg = scratch; masm.ma_li(rhsReg, ImmWord(ToInt64(rhs))); - } else { + } else if (rhs.value().isGeneralReg()) { rhsReg = ToRegister64(rhs).reg; + } else { + rhsReg = scratch; + masm.loadPtr(ToAddress(rhs.value()), rhsReg); } bool isSigned = mir->compareType() == MCompare::Compare_Int64;