-/* The core algorithm. *****************************************/
-
-static void scc (ir_node *n) {
- int i;
- ir_graph *rem;
-
- if (irn_visited(n)) return;
- mark_irn_visited(n);
- /*printf("mark: %d ", get_irn_visited(n)); DDMN(n);
- DDME(get_irg_ent(current_ir_graph));*/
-
- /* Initialize the node */
- set_irn_dfn(n, current_dfn); /* Depth first number for this node */
- set_irn_uplink(n, current_dfn); /* ... is default uplink. */
- set_irn_loop(n, NULL);
- current_dfn ++;
-
- /* What's this good for?
- n->ana.scc.section = NULL;
- */
-
- push(n);
-
- /* AS: get_start_index might return -1 for Control Flow Nodes, and thus a negative
- array index would be passed to is_backedge(). But CFG Nodes dont't have a backedge array,
- so is_backedge does not access array[-1] but correctly returns false! */
-
- if (!is_outermost_Start(n)) {
- for (i = get_start_index(n); i < get_irn_arity(n); i++) {
- ir_node *m;
- if (is_backedge(n, i)) continue;
-
- m = get_irn_n(n, i); /*get_irn_ip_pred(n, i);*/
- if ((!m) || (get_irn_op(m) == op_Unknown)) continue;
- scc (m);
- /*return_recur(n, i);*/
-
- if (irn_is_in_stack(m)) {
- /* Uplink of m is smaller if n->m is a backedge.
- Propagate the uplink to mark the loop. */
- if (get_irn_uplink(m) < get_irn_uplink(n))
- set_irn_uplink(n, get_irn_uplink(m));
- }
- }
- }
-
- if (get_irn_dfn(n) == get_irn_uplink(n)) {
- /* This condition holds for the node with the incoming backedge.
- AS: That is: For the loop head. */
- ir_node *tail = find_tail(n);
- if (tail) {
- /* We found a new inner loop! */
- ir_loop *l = new_loop();
-
- /* Remove the loop from the stack ... */
- pop_scc_unmark_visit (n);
- /* and recompute it in a better order; and so that it goes into
- the new loop. */
- rem = find_irg_on_stack(tail);
-
- scc (tail);
- current_ir_graph = rem;
-
- assert (irn_visited(n));
- close_loop(l);
- } else {
- /* AS: No inner loop was found. Pop all nodes from the stack
- to the current loop. */
- pop_scc_to_loop(n);
- }
- }
+ /* The current backedge has been marked, that is temporarily eliminated,
+ by find tail. Start the scc algorithm
+ again on the subgraph that is left (the current loop without the backedge)
+ in order to find more inner loops. */
+ scc(tail);
+
+ assert(irn_visited(n));
+#if NO_LOOPS_WITHOUT_HEAD
+ if (close)
+#endif
+ close_loop(l);
+ } else {
+ /* No loop head was found, that is we have straight line code.
+ Pop all nodes from the stack to the current loop. */
+ pop_scc_to_loop(n);
+ }
+ }