Bug 891070 - IonMonkey: RangeAnalysis simplifications. r=nbp
authorDan Gohman <sunfish@google.com>
Mon, 08 Jul 2013 20:26:27 -0700
changeset 137705 600df52eb174819ded629fa31f41db4f117bc577
parent 137704 c42922a413746c3bc9da6f7074d55b4ec7f9f74b
child 137706 9f542b4bfbfa80855d91bfb3db64168bf5c5bb67
child 137721 b04e6266d457e73d68a3e027fcd02362bf92dbf4
push id30660
push usersunfish@google.com
push dateTue, 09 Jul 2013 03:30:41 +0000
treeherdermozilla-inbound@600df52eb174 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnbp
bugs891070
milestone25.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 891070 - IonMonkey: RangeAnalysis simplifications. r=nbp
js/src/ion/MIRGraph.h
js/src/ion/RangeAnalysis.cpp
--- a/js/src/ion/MIRGraph.h
+++ b/js/src/ion/MIRGraph.h
@@ -604,16 +604,19 @@ class MIRGraph
         return blocks_.rbegin();
     }
     PostorderIterator poEnd() {
         return blocks_.rend();
     }
     ReversePostorderIterator rpoBegin() {
         return blocks_.begin();
     }
+    ReversePostorderIterator rpoBegin(MBasicBlock *at) {
+        return blocks_.begin(at);
+    }
     ReversePostorderIterator rpoEnd() {
         return blocks_.end();
     }
     void removeBlocksAfter(MBasicBlock *block);
     void removeBlock(MBasicBlock *block);
     void moveBlockToEnd(MBasicBlock *block) {
         JS_ASSERT(block->id());
         blocks_.remove(block);
--- a/js/src/ion/RangeAnalysis.cpp
+++ b/js/src/ion/RangeAnalysis.cpp
@@ -1039,16 +1039,18 @@ RangeAnalysis::markBlocksInLoopBody(MBas
             markBlocksInLoopBody(header, current->getPredecessor(i));
         }
     }
 }
 
 void
 RangeAnalysis::analyzeLoop(MBasicBlock *header)
 {
+    JS_ASSERT(header->hasUniqueBackedge());
+
     // Try to compute an upper bound on the number of times the loop backedge
     // will be taken. Look for tests that dominate the backedge and which have
     // an edge leaving the loop body.
     MBasicBlock *backedge = header->backedge();
 
     // Ignore trivial infinite loops.
     if (backedge == header)
         return;
@@ -1092,27 +1094,24 @@ RangeAnalysis::analyzeLoop(MBasicBlock *
         IonSpew(IonSpew_Range, "computed symbolic bound on backedges: %s",
                 sp.string());
     }
 #endif
 
     // Try to compute symbolic bounds for the phi nodes at the head of this
     // loop, expressed in terms of the iteration bound just computed.
 
-    for (MDefinitionIterator iter(header); iter; iter++) {
-        MDefinition *def = *iter;
-        if (def->isPhi())
-            analyzeLoopPhi(header, iterationBound, def->toPhi());
-    }
+    for (MPhiIterator iter(header->phisBegin()); iter != header->phisEnd(); iter++)
+        analyzeLoopPhi(header, iterationBound, *iter);
 
     // Try to hoist any bounds checks from the loop using symbolic bounds.
 
     Vector<MBoundsCheck *, 0, IonAllocPolicy> hoistedChecks;
 
-    for (ReversePostorderIterator iter(graph_.rpoBegin()); iter != graph_.rpoEnd(); iter++) {
+    for (ReversePostorderIterator iter(graph_.rpoBegin(header)); iter != graph_.rpoEnd(); iter++) {
         MBasicBlock *block = *iter;
         if (!block->isMarked())
             continue;
 
         for (MDefinitionIterator iter(block); iter; iter++) {
             MDefinition *def = *iter;
             if (def->isBoundsCheck() && def->isMovable()) {
                 if (tryHoistBoundsCheck(header, def->toBoundsCheck()))
@@ -1253,18 +1252,17 @@ RangeAnalysis::analyzeLoopPhi(MBasicBloc
 {
     // Given a bound on the number of backedges taken, compute an upper and
     // lower bound for a phi node that may change by a constant amount each
     // iteration. Unlike for the case when computing the iteration bound
     // itself, the phi does not need to change the same amount every iteration,
     // but is required to change at most N and be either nondecreasing or
     // nonincreasing.
 
-    if (phi->numOperands() != 2)
-        return;
+    JS_ASSERT(phi->numOperands() == 2);
 
     MBasicBlock *preLoop = header->loopPredecessor();
     JS_ASSERT(!preLoop->isMarked() && preLoop->successorWithPhis() == header);
 
     MBasicBlock *backedge = header->backedge();
     JS_ASSERT(backedge->isMarked() && backedge->successorWithPhis() == header);
 
     MDefinition *initial = phi->getOperand(preLoop->positionInPhiSuccessor());