Home | History | Annotate | Download | only in gcc

Lines Matching refs:loop

40   hwloop_info loop;
42 for (loop = loops; loop; loop = loop->next)
48 fprintf (dump_file, ";; loop %d: ", loop->loop_no);
49 if (loop->bad)
52 loop->head == NULL ? -1 : loop->head->index,
53 loop->depth, REGNO (loop->iter_reg));
56 for (ix = 0; loop->blocks.iterate (ix, &b); ix++)
61 for (ix = 0; loop->loops.iterate (ix, &i); ix++)
68 /* Return true if BB is part of LOOP. */
70 bb_in_loop_p (hwloop_info loop, basic_block bb)
72 return bitmap_bit_p (loop->block_bitmap, bb->index);
75 /* Scan the blocks of LOOP (and its inferiors), and record things such as
76 hard registers set, jumps out of and within the loop. */
78 scan_loop (hwloop_info loop)
83 if (loop->bad)
86 if (REGNO_REG_SET_P (df_get_live_in (loop->successor),
87 REGNO (loop->iter_reg)))
88 loop->iter_reg_used_outside = true;
90 for (ix = 0; loop->blocks.iterate (ix, &bb); ix++)
96 if (bb != loop->tail)
99 if (bb_in_loop_p (loop, e->dest))
102 loop->jumps_within = true;
106 loop->jumps_outof = true;
107 if (!loop->bad)
109 REGNO (loop->iter_reg)));
126 loop->has_asm = true;
140 if (insn == loop->loop_end)
141 CLEAR_HARD_REG_BIT (set_this_insn, REGNO (loop->iter_reg));
142 else if (reg_mentioned_p (loop->iter_reg, PATTERN (insn)))
143 loop->iter_reg_used = true;
144 loop->regs_set_in_loop |= set_this_insn;
149 /* Compute the incoming_dest and incoming_src members of LOOP by
150 identifying the edges that jump into the loop. If there is more
151 than one block that jumps into the loop, incoming_src will be set
152 to NULL; likewise, if there is more than one block in the loop that
158 process_incoming_edges (hwloop_info loop)
164 FOR_EACH_EDGE (e, ei, loop->incoming)
168 loop->incoming_src = e->src;
169 loop->incoming_dest = e->dest;
174 if (e->dest != loop->incoming_dest)
175 loop->incoming_dest = NULL;
176 if (e->src != loop->incoming_src)
177 loop->incoming_src = NULL;
180 if (loop->incoming_src == NULL && loop->incoming_dest == NULL)
186 /* Try to identify a forwarder block that jump into LOOP, and add it to
187 the set of blocks in the loop, updating the vector of incoming blocks as
193 add_forwarder_blocks (hwloop_info loop)
198 FOR_EACH_EDGE (e, ei, loop->incoming)
207 ";; Adding forwarder block %d to loop %d and retrying\n",
208 e->src->index, loop->loop_no);
209 loop->blocks.safe_push (e->src);
210 bitmap_set_bit (loop->block_bitmap, e->src->index);
212 vec_safe_push (loop->incoming, e2);
213 loop->incoming->unordered_remove (ei.index);
220 /* Called from reorg_loops when a potential loop end is found. LOOP is
221 a newly set up structure describing the loop, it is this function's
223 loop_end insn and its enclosing basic block. REG is the loop counter
225 For our purposes, a loop is defined by the set of blocks reachable from
226 the loop head in which the loop counter register is live. This matches
228 loop counter with a different special register. */
230 discover_loop (hwloop_info loop, basic_block tail_bb, rtx_insn *tail_insn, rtx reg)
236 loop->tail = tail_bb;
237 loop->loop_end = tail_insn;
238 loop->iter_reg = reg;
239 vec_alloc (loop->incoming, 2);
240 loop->start_label = as_a <rtx_insn *> (JUMP_LABEL (tail_insn));
244 loop->bad = true;
247 loop->head = BRANCH_EDGE (tail_bb)->dest;
248 loop->successor = FALLTHRU_EDGE (tail_bb)->dest;
251 works.safe_push (loop->head);
260 /* We've reached the exit block. The loop must be bad. */
263 ";; Loop is bad - reached exit block while scanning\n");
264 loop->bad = true;
268 if (bitmap_bit_p (loop->block_bitmap, bb->index))
271 /* We've not seen this block before. Add it to the loop's
274 loop->blocks.safe_push (bb);
275 bitmap_set_bit (loop->block_bitmap, bb->index);
285 REGNO (loop->iter_reg)))
292 loop->bad = true;
294 /* Find the predecessor, and make sure nothing else jumps into this loop. */
295 if (!loop->bad)
297 FOR_EACH_VEC_ELT (loop->blocks, dwork, bb)
305 if (!bb_in_loop_p (loop, pred))
308 fprintf (dump_file, ";; Loop %d: incoming edge %d -> %d\n",
309 loop->loop_no, pred->index,
311 vec_safe_push (loop->incoming, e);
316 if (!process_incoming_edges (loop))
320 ";; retrying loop %d with forwarder blocks\n",
321 loop->loop_no);
322 if (!add_forwarder_blocks (loop))
326 loop->bad = true;
328 else if (!process_incoming_edges (loop))
332 ";; can't find suitable entry for loop %d\n",
333 loop->loop_no);
348 hwloop_info loop;
352 /* Find all the possible loop tails. This means searching for every
373 /* A possible loop end */
375 /* There's a degenerate case we can handle - an empty loop consisting
385 fprintf (dump_file, ";; degenerate loop ending at\n");
397 loop = XCNEW (struct hwloop_info_d);
398 loop->next = loops;
399 loops = loop;
400 loop->loop_no = nloops++;
401 loop->blocks.create (20);
402 loop->block_bitmap = BITMAP_ALLOC (loop_stack);
406 fprintf (dump_file, ";; potential loop %d ending at\n",
407 loop->loop_no);
411 discover_loop (loop, bb, tail, reg);
414 /* Compute loop nestings. Given two loops A and B, either the sets
417 for (loop = loops; loop; loop = loop->next)
421 if (loop->bad)
429 if (!bitmap_intersect_p (other->block_bitmap, loop->block_bitmap))
432 loop->block_bitmap))
433 loop->loops.safe_push (other);
434 else if (!bitmap_intersect_compl_p (loop->block_bitmap,
436 other->loops.safe_push (loop);
442 loop->loop_no, other->loop_no);
443 loop->bad = other->bad = true;
454 /* Free up the loop structures in LOOPS. */
460 hwloop_info loop = loops;
461 loops = loop->next;
462 loop->loops.release ();
463 loop->blocks.release ();
464 BITMAP_FREE (loop->block_bitmap);
465 XDELETE (loop);
483 /* The taken-branch edge from the loop end can actually go forward.
484 If the target's hardware loop support requires that the loop end be
485 after the loop start, try to reorder a loop's basic blocks when we
494 hwloop_info loop;
500 for (loop = loops; loop; loop = loop->next)
505 if (loop->bad)
508 if (BB_AUX_INDEX (loop->head) <= BB_AUX_INDEX (loop->tail))
511 FOR_EACH_EDGE (e, ei, loop->head->succs)
513 if (bitmap_bit_p (loop->block_bitmap, e->dest->index)
514 && BB_AUX_INDEX (e->dest) < BB_AUX_INDEX (loop->tail))
521 loop->head->index, start_bb->index);
522 loop->head->prev_bb->next_bb = loop->head->next_bb;
523 loop->head->next_bb->prev_bb = loop->head->prev_bb;
525 loop->head->prev_bb = start_prev_bb;
526 loop->head->next_bb = start_bb;
527 start_prev_bb->next_bb = start_bb->prev_bb = loop->head;
548 /* Call the OPT function for LOOP and all of its sub-loops. This is
553 optimize_loop (hwloop_info loop, struct hw_doloop_hooks *hooks)
559 if (loop->visited)
562 loop->visited = 1;
564 if (loop->bad)
567 fprintf (dump_file, ";; loop %d bad when found\n", loop->loop_no);
571 /* Every loop contains in its list of inner loops every loop nested inside
573 a depth-first search here and never visit a loop more than once.
576 for (ix = 0; loop->loops.iterate (ix, &inner); ix++)
583 loop. */
584 loop->regs_set_in_loop |= inner->regs_set_in_loop;
587 loop->depth = inner_depth + 1;
589 if (hooks->opt (loop))
594 fprintf (dump_file, ";; loop %d is bad\n", loop->loop_no);
596 loop->bad = true;
597 hooks->fail (loop);
607 instructions before the loop, to define loop bounds or set up a
608 special loop counter register.
611 loop end occurs after the loop
612 start. This is for use by targets where the loop hardware requires
621 hwloop_info loop;
648 for (loop = loops; loop; loop = loop->next)
649 scan_loop (loop);
652 for (loop = loops; loop; loop = loop->next)
653 optimize_loop (loop, hooks);