Lines Matching full:loop
36 // Utility class to perform the peeling of a given loop.
37 // The loop peeling transformation make a certain amount of a loop iterations to
39 // loop.
42 // - It clones the loop and inserts the cloned loop before the original loop;
43 // - It connects all iterating values of the cloned loop with the
44 // corresponding original loop values so that the second loop starts with
51 // The exit condition of the cloned loop is changed so that the loop
52 // exits when "i < N" becomes false. The original loop is then protected to
55 // then the exit condition of the cloned loop is changed so that the loop
57 // is the upper bound of the loop. The cloned loop is then protected to
62 // - The loop must be in LCSSA form;
63 // - The loop must not contain any breaks;
64 // - The loop must not have any ambiguous iterators updates (see
70 // |loop| is the loop to peel.
71 // |loop_iteration_count| is the instruction holding the |loop| iteration
72 // count, must be invariant for |loop| and must be of an int 32 type (signed
79 LoopPeeling(Loop* loop, Instruction* loop_iteration_count,
81 : context_(loop->GetContext()),
82 loop_utils_(loop->GetContext(), loop),
83 loop_(loop),
84 loop_iteration_count_(!loop->IsInsideLoop(loop_iteration_count)
105 // Returns true if the loop can be peeled.
106 // To be peelable, all operation involved in the update of the loop iterators
116 // This restriction will not apply if a loop rotate is applied before (i.e.
117 // becomes a do-while loop).
149 // Moves the execution of the |factor| first iterations of the loop into a
150 // dedicated loop.
153 // Moves the execution of the |factor| last iterations of the loop into a
154 // dedicated loop.
157 // Returns the cloned loop.
158 Loop* GetClonedLoop() { return cloned_loop_; } in GetClonedLoop()
159 // Returns the original loop.
160 Loop* GetOriginalLoop() { return loop_; } in GetOriginalLoop()
165 // The original loop.
166 Loop* loop_;
171 // The cloned loop.
172 Loop* cloned_loop_;
176 // The canonical induction variable from the original loop if it exists.
178 // The canonical induction variable of the cloned loop. The induction variable
181 // Map between loop iterators and exit values. Loop iterators
184 // Duplicate |loop_| and place the new loop before the cloned loop. Iterating
185 // values from the cloned loop are then connected to the original loop as
189 // Insert the canonical induction variable into the first loop as a simplified
194 // Fixes the exit condition of the before loop. The function calls
196 // of the loop exit. The loop will be exited if the condition evaluate to
205 const Loop* loop, Instruction* iterator,
209 // iterating value in the loop (a phi instruction in the loop header) and its
210 // SSA value when it exit the loop. If no exit value can be accurately found,
214 // Returns true if a for-loop has no instruction with effects before the
222 // Inserts code to only execute |loop| only if the given |condition| is true.
225 // The function returns the if block protecting the loop.
226 BasicBlock* ProtectLoop(Loop* loop, Instruction* condition,
230 // Implements a loop peeling optimization.
231 // For each loop, the pass will try to peel it if there is conditions that
232 // are true for the "N" first or last iterations of the loop.
245 std::vector<std::tuple<const Loop*, PeelDirection, uint32_t>> peeled_loops_;
250 // Sets the loop peeling growth threshold. If the code size increase is above
251 // |code_grow_threshold|, the loop will not be peeled. The code size is
257 // Returns the loop peeling code growth threshold.
260 const char* name() const override { return "loop-peeling"; } in name()
280 LoopPeelingInfo(Loop* loop, size_t loop_max_iterations, in LoopPeelingInfo() argument
282 : context_(loop->GetContext()), in LoopPeelingInfo()
283 loop_(loop), in LoopPeelingInfo()
287 // Returns by how much and to which direction a loop should be peeled to
294 // Returns the id of the loop invariant operand of the conditional
297 // Returns the id of the non loop invariant operand of the conditional
301 // Returns the value of |rec| at the first loop iteration.
306 // Returns the value of |rec| at the last loop iteration.
320 Loop* loop_;
326 // Peel |loop| if profitable.
327 std::pair<bool, Loop*> ProcessLoop(Loop* loop, CodeMetrics* loop_size);