From 649691e4ac0fbd211bda475af5c6948e572ca112 Mon Sep 17 00:00:00 2001 From: Sander Mathijs van Veen Date: Fri, 26 Jun 2015 00:18:20 +0200 Subject: [PATCH] Bug 1176864 - Truncate modulo operator for int32 r=h4writer, r=nbp --- js/src/jit/RangeAnalysis.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/js/src/jit/RangeAnalysis.cpp b/js/src/jit/RangeAnalysis.cpp index 955d9ca3860..d6428b21784 100644 --- a/js/src/jit/RangeAnalysis.cpp +++ b/js/src/jit/RangeAnalysis.cpp @@ -2902,10 +2902,13 @@ ComputeTruncateKind(MDefinition* candidate, bool* shouldClone) const Range* r = candidate->range(); bool canHaveRoundingErrors = !r || r->canHaveRoundingErrors(); - // Special case integer division: the result of a/b can be infinite - // but cannot actually have rounding errors induced by truncation. - if (candidate->isDiv() && candidate->toDiv()->specialization() == MIRType_Int32) + // Special case integer division and modulo: a/b can be infinite, and a%b + // can be NaN but cannot actually have rounding errors induced by truncation. + if ((candidate->isDiv() || candidate->isMod()) && + static_cast(candidate)->specialization() == MIRType_Int32) + { canHaveRoundingErrors = false; + } if (canHaveRoundingErrors) return MDefinition::NoTruncate;