Fully unroll the loop by partially unrolling it by the number of loop iterations minus one for the body already accounted for.
| 590 | // Fully unroll the loop by partially unrolling it by the number of loop |
| 591 | // iterations minus one for the body already accounted for. |
| 592 | bool LoopUnrollerUtilsImpl::FullyUnroll(Loop* loop) { |
| 593 | // We unroll the loop by number of iterations in the loop. |
| 594 | if (!Unroll(loop, number_of_loop_iterations_)) { |
| 595 | return false; |
| 596 | } |
| 597 | |
| 598 | // The first condition block is preserved until now so it can be copied. |
| 599 | if (!FoldConditionBlock(loop_condition_block_, 1)) { |
| 600 | return false; |
| 601 | } |
| 602 | |
| 603 | // Delete the OpLoopMerge and remove the backedge to the header. |
| 604 | CloseUnrolledLoop(loop); |
| 605 | |
| 606 | // Mark the loop for later deletion. This allows us to preserve the loop |
| 607 | // iterators but still disregard dead loops. |
| 608 | loop->MarkLoopForRemoval(); |
| 609 | |
| 610 | // If the loop has a parent add the new blocks to the parent. |
| 611 | if (loop->GetParent()) { |
| 612 | AddBlocksToLoop(loop->GetParent()); |
| 613 | } |
| 614 | |
| 615 | // Add the blocks to the function. |
| 616 | AddBlocksToFunction(loop->GetMergeBlock()); |
| 617 | |
| 618 | ReplaceInductionUseWithFinalValue(loop); |
| 619 | |
| 620 | RemoveDeadInstructions(); |
| 621 | // Invalidate all analyses. |
| 622 | context_->InvalidateAnalysesExceptFor( |
| 623 | IRContext::Analysis::kAnalysisLoopAnalysis | |
| 624 | IRContext::Analysis::kAnalysisDefUse); |
| 625 | return true; |
| 626 | } |
| 627 | |
| 628 | void LoopUnrollerUtilsImpl::KillDebugDeclares(BasicBlock* bb) { |
| 629 | // We cannot kill an instruction inside BasicBlock::ForEachInst() |
no test coverage detected