Bug 1176864 - Truncate modulo operator for int32 r=h4writer, r=nbp
authorSander Mathijs van Veen <smvv@kompiler.org>
Fri, 26 Jun 2015 00:18:20 +0200
changeset 250689 48efca5bf907d33f7ace80f136d7c5868b14c5f8
parent 250688 f3b6460a443c3cb9eaf5885a3f5adcff8d621b31
child 250690 c259755b88fe58db570a276c5d243eae48096502
push idunknown
push userunknown
push dateunknown
reviewersh4writer, nbp
bugs1176864
milestone42.0a1
Bug 1176864 - Truncate modulo operator for int32 r=h4writer, r=nbp
js/src/jit/RangeAnalysis.cpp
--- a/js/src/jit/RangeAnalysis.cpp
+++ b/js/src/jit/RangeAnalysis.cpp
@@ -2897,20 +2897,23 @@ ComputeTruncateKind(MDefinition* candida
 
     // Set truncated flag if range analysis ensure that it has no
     // rounding errors and no fractional part. Note that we can't use
     // the MDefinition Range constructor, because we need to know if
     // the value will have rounding errors before any bailout checks.
     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<const MBinaryArithInstruction *>(candidate)->specialization() == MIRType_Int32)
+    {
         canHaveRoundingErrors = false;
+    }
 
     if (canHaveRoundingErrors)
         return MDefinition::NoTruncate;
 
     // Ensure all observable uses are truncated.
     return ComputeRequestedTruncateKind(candidate, shouldClone);
 }