Lines Matching defs:loop

5 #include "src/compiler/loop-peeling.h"
10 #include "src/compiler/loop-analysis.h"
17 // Loop peeling is an optimization that copies the body of a loop, creating
19 // first iteration. Beginning with a loop as follows:
46 // The body of the loop is duplicated so that all nodes considered "inside"
47 // the loop (e.g. {P, U, X, Y, K, L, M}) have a corresponding copies in the
49 // backedges of the loop correspond to edges from the peeled iteration to
50 // the main loop body, with multiple backedges requiring a merge.
52 // Similarly, any exits from the loop body need to be merged with "exits"
125 PeeledIteration* LoopPeeler::Peel(LoopTree::Loop* loop) {
126 if (!CanPeel(loop)) return nullptr;
132 uint32_t estimated_peeled_size = 5 + loop->TotalSize() * 2;
137 // Map the loop header nodes to their entry values.
138 for (Node* node : loop_tree_->HeaderNodes(loop)) {
142 // Copy all the nodes of loop body for the peeled iteration.
143 copier.CopyNodes(graph_, tmp_zone_, dead, loop_tree_->BodyNodes(loop),
147 // Replace the entry to the loop with the output of the peeled iteration.
149 Node* loop_node = loop_tree_->GetLoopControl(loop);
153 // Multiple backedges from original loop, therefore multiple output edges
163 for (Node* node : loop_tree_->HeaderNodes(loop)) {
181 // Only one backedge, simply replace the input to loop with output of
183 for (Node* node : loop_tree_->HeaderNodes(loop)) {
193 for (Node* exit : loop_tree_->ExitNodes(loop)) {
196 // Change the loop exit node to a merge node.
218 void LoopPeeler::PeelInnerLoops(LoopTree::Loop* loop) {
219 // If the loop has nested loops, peel inside those.
220 if (!loop->children().empty()) {
221 for (LoopTree::Loop* inner_loop : loop->children()) {
227 if (loop->TotalSize() > LoopPeeler::kMaxPeeledNodes) return;
229 PrintF("Peeling loop with header: ");
230 for (Node* node : loop_tree_->HeaderNodes(loop)) {
236 Peel(loop);
241 // The exit markers take the loop exit as input. We iterate over uses
262 for (LoopTree::Loop* loop : loop_tree_->outer_loops()) {
263 PeelInnerLoops(loop);