Bug 1315640: Split unnecessary loop into linear code; r?nbp draft
authorBenjamin Bouvier <benj@benj.me>
Mon, 07 Nov 2016 11:35:30 +0100
changeset 434791 3eda6f3a234a40e5e4140682ee72b493a989178c
parent 434790 7c1c7953fe42420d2a66951b9b1d46171cf0d044
child 536116 378f3d757a4814924254139343ec2abe05148a50
push id34825
push userbbouvier@mozilla.com
push dateMon, 07 Nov 2016 10:38:21 +0000
reviewersnbp
bugs1315640
milestone52.0a1
Bug 1315640: Split unnecessary loop into linear code; r?nbp MozReview-Commit-ID: 9EExrHvQqac
js/src/jit/MIR.cpp
--- a/js/src/jit/MIR.cpp
+++ b/js/src/jit/MIR.cpp
@@ -2794,21 +2794,20 @@ MBinaryBitwiseInstruction::foldUnnecessa
 {
     if (specialization_ != MIRType::Int32)
         return this;
 
     // Fold unsigned shift right operator when the second operand is zero and
     // the only use is an unsigned modulo. Thus, the expression
     // |(x >>> 0) % y| becomes |x % y|.
     if (isUrsh() && hasOneDefUse() && IsUint32Type(this)) {
-        for (MUseDefIterator use(this); use; use++) {
-            if (use.def()->isMod() && use.def()->toMod()->isUnsigned())
-                return getOperand(0);
-            break;
-        }
+        MUseDefIterator use(this);
+        if (use.def()->isMod() && use.def()->toMod()->isUnsigned())
+            return getOperand(0);
+        MOZ_ASSERT(!(++use));
     }
 
     // Eliminate bitwise operations that are no-ops when used on integer
     // inputs, such as (x | 0).
 
     MDefinition* lhs = getOperand(0);
     MDefinition* rhs = getOperand(1);