Home | History | Annotate | Download | only in optimizing

Lines Matching defs:loop

285  * of an existing value range, NewArray or a loop phi corresponding to an
486 const int32_t increment_; // Increment for each loop iteration.
504 // Added blocks for loop body entry test.
564 // Clear the loop data structures.
615 // Make sure the comparison is in the loop header so each increment is
635 // Comparison needs to be in loop header to make sure it's done after each
711 // if it's not defined in the loop header.
885 // Try loop-based dynamic elimination.
886 HLoopInformation* loop = bounds_check->GetBlock()->GetLoopInformation();
889 if (DynamicBCESeemsProfitable(loop, bounds_check->GetBlock()) &&
892 CanHandleInfiniteLoop(loop, index, needs_finite_test) &&
894 CanHandleLength(loop, array_length, needs_taken_test)) {
895 TransformLoopForDeoptimizationIfNeeded(loop, needs_taken_test);
896 TransformLoopForDynamicBCE(loop, bounds_check);
1011 // such as the inner loop 'for (int j=0; j<array.length-i; j++)' where i
1012 // is the index for outer loop. In this case, we know j is bounded by array.length-1.
1150 * may be exposed underneath which can be hoisted out of the loop to the
1161 * unsafe to hoist array references across their deoptimization instruction inside a loop.
1165 HLoopInformation* loop = array_get->GetBlock()->GetLoopInformation();
1166 if (loop->IsDefinedOutOfTheLoop(array_get->InputAt(0)) &&
1167 loop->IsDefinedOutOfTheLoop(array_get->InputAt(1))) {
1168 SideEffects loop_effects = side_effects_.GetLoopEffects(loop->GetHeader());
1172 if (loop->DominatesAllBackEdges(array_get->GetBlock())) {
1173 HoistToPreHeaderOrDeoptBlock(loop, array_get);
1323 // use analysis for static bce only if loop is finite.
1336 * Performs loop-based dynamic elimination on a bounds check. In order to minimize the
1340 void TransformLoopForDynamicBCE(HLoopInformation* loop, HBoundsCheck* bounds_check) {
1343 DCHECK(loop->IsDefinedOutOfTheLoop(array_length)); // pre-checked
1344 DCHECK(loop->DominatesAllBackEdges(bounds_check->GetBlock()));
1345 // Collect all bounds checks in the same loop that are related as "a[base + constant]"
1357 if (user->IsBoundsCheck() && loop == user->GetBlock()->GetLoopInformation()) {
1371 if (!loop->DominatesAllBackEdges(user->GetBlock())) {
1389 // Perform loop-based deoptimization if it seems profitable, where we eliminate bounds
1395 HBasicBlock* block = GetPreHeader(loop, bounds_check);
1409 // It handles either loop invariants (lower is not set) or unit strides.
1440 InsertDeoptInLoop(loop, block, new (GetGraph()->GetArena()) HAbove(min_upper, max_upper));
1450 InsertDeoptInLoop(loop, block, new (GetGraph()->GetArena()) HAbove(min_lower, max_lower));
1455 InsertDeoptInLoop(loop, block, new (GetGraph()->GetArena()) HAbove(max_lower, max_upper));
1458 loop, block, new (GetGraph()->GetArena()) HAboveOrEqual(max_upper, array_length));
1467 bool DynamicBCESeemsProfitable(HLoopInformation* loop, HBasicBlock* block) {
1468 if (loop != nullptr) {
1469 // The loop preheader of an irreducible loop does not dominate all the blocks in
1470 // the loop. We would need to find the common dominator of all blocks in the loop.
1471 if (loop->IsIrreducible()) {
1481 if (loop->GetPreHeader()->GetLastInstruction()->IsTryBoundary()) {
1484 // Does loop have early-exits? If so, the full range may not be covered by the loop
1486 if (IsEarlyExitLoop(loop)) {
1491 return loop->DominatesAllBackEdges(block);
1497 * Returns true if the loop has early exits, which implies it may not cover
1500 bool IsEarlyExitLoop(HLoopInformation* loop) {
1501 const uint32_t loop_id = loop->GetHeader()->GetBlockId();
1502 // If loop has been analyzed earlier for early-exit, don't repeat the analysis.
1507 // First time early-exit analysis for this loop. Since analysis requires scanning
1508 // the full loop-body, results of the analysis is stored for subsequent queries.
1509 HBlocksInLoopReversePostOrderIterator it_loop(*loop);
1512 if (!loop->Contains(*successor)) {
1523 * Returns true if the array length is already loop invariant, or can be made so
1526 bool CanHandleLength(HLoopInformation* loop, HInstruction* length, bool needs_taken_test) {
1527 if (loop->IsDefinedOutOfTheLoop(length)) {
1529 } else if (length->IsArrayLength() && length->GetBlock()->GetLoopInformation() == loop) {
1530 if (CanHandleNullCheck(loop, length->InputAt(0), needs_taken_test)) {
1531 HoistToPreHeaderOrDeoptBlock(loop, length);
1539 * Returns true if the null check is already loop invariant, or can be made so
1542 bool CanHandleNullCheck(HLoopInformation* loop, HInstruction* check, bool needs_taken_test) {
1543 if (loop->IsDefinedOutOfTheLoop(check)) {
1545 } else if (check->IsNullCheck() && check->GetBlock()->GetLoopInformation() == loop) {
1547 if (loop->IsDefinedOutOfTheLoop(array)) {
1549 TransformLoopForDeoptimizationIfNeeded(loop, needs_taken_test);
1550 HBasicBlock* block = GetPreHeader(loop, check);
1553 InsertDeoptInLoop(loop, block, cond, /* is_null_check */ true);
1566 * of the loop to use, dynamic bce in such cases is only allowed if other tests
1567 * ensure the loop is finite.
1569 bool CanHandleInfiniteLoop(HLoopInformation* loop, HInstruction* index, bool needs_infinite_test) {
1571 // If we already forced the loop to be finite, allow directly.
1572 const uint32_t loop_id = loop->GetHeader()->GetBlockId();
1577 // this point) is the direct loop index (viz. a[i]), since then the runtime tests
1578 // ensure upper bound cannot cause an infinite loop.
1579 HInstruction* control = loop->GetHeader()->GetLastInstruction();
1597 * Returns appropriate preheader for the loop, depending on whether the
1598 * instruction appears in the loop header or proper loop-body.
1600 HBasicBlock* GetPreHeader(HLoopInformation* loop, HInstruction* instruction) {
1603 HBasicBlock* header = loop->GetHeader();
1615 return loop->GetPreHeader();
1618 /** Inserts a deoptimization test in a loop preheader. */
1619 void InsertDeoptInLoop(HLoopInformation* loop,
1623 HInstruction* suspend = loop->GetSuspendCheck();
1632 suspend->GetEnvironment(), loop->GetHeader());
1646 /** Hoists instruction out of the loop to preheader or deoptimization block. */
1647 void HoistToPreHeaderOrDeoptBlock(HLoopInformation* loop, HInstruction* instruction) {
1648 HBasicBlock* block = GetPreHeader(loop, instruction);
1654 * Adds a new taken-test structure to a loop if needed and not already done.
1668 * For example, this loop:
1685 * // Loop without null check and bounds check, and any array.length replaced with array_length.
1689 void TransformLoopForDeoptimizationIfNeeded(HLoopInformation* loop, bool needs_taken_test) {
1691 const uint32_t loop_id = loop->GetHeader()->GetBlockId();
1697 HBasicBlock* header = loop->GetHeader();
1699 HBasicBlock* new_preheader = loop->GetPreHeader();
1709 // Insert the taken-test to see if the loop body is entered. If the
1710 // loop isn't entered at all, it jumps around the deoptimization block.
1723 * All uses of instructions in the deoptimization block that reach the loop need
1724 * a phi node in the new loop preheader to fix the dominance relation.
1824 // Early-exit loop bookkeeping.
1827 // Taken-test loop bookkeeping.
1830 // Finite loop bookkeeping.