diff --git a/js/src/ion/MIR.h b/js/src/ion/MIR.h index fc400485493..a8657dffa03 100644 --- a/js/src/ion/MIR.h +++ b/js/src/ion/MIR.h @@ -2486,7 +2486,7 @@ class MMul : public MBinaryArithInstruction } bool canBeNegativeZero() { - if (range()->lower() >= 0 && range()->upper() >= 0) + if (range()->lower() > 0 || range()->upper() < 0) return false; return canBeNegativeZero_; } @@ -2589,11 +2589,16 @@ class MMod : public MBinaryArithInstruction bool recomputeRange() { if (specialization() != MIRType_Int32) return false; - Range *other = getOperand(0)->range(); - int64_t a = Range::abs64((int64_t)other->lower()); - int64_t b = Range::abs64((int64_t)other->upper()); - Range r(Min(-a+1, -b+1), - Max( a-1, b-1)); + Range *rhs = getOperand(1)->range(); + int64_t a = Range::abs64((int64_t)rhs->lower()); + int64_t b = Range::abs64((int64_t)rhs->upper()); + if (a ==0 && b == 0) { + // We should never take something % 0. + Range r(INT_MIN, INT_MAX); + return range()->update(r); + } + int64_t bound = Max(1-a, b-1); + Range r(-bound, bound); return range()->update(r); } }; diff --git a/js/src/ion/RangeAnalysis.cpp b/js/src/ion/RangeAnalysis.cpp index 4ec201b4e75..51e9cd44db0 100644 --- a/js/src/ion/RangeAnalysis.cpp +++ b/js/src/ion/RangeAnalysis.cpp @@ -272,8 +272,10 @@ Range::intersect(const Range *lhs, const Range *rhs, bool *nullRange) // // Instead, we should use it to eliminate the dead block. // (Bug 765127) - if (r.upper_ < r.lower_) + if (r.upper_ < r.lower_) { + *nullRange = true; r.makeRangeInfinite(); + } return r; }