-/* Find the root node of the loop pre-header extended basic block and
- the edges along the trace from the root node to the loop header. */
-
-static void
-flow_loop_pre_header_scan (struct loop *loop)
-{
- int num;
- basic_block ebb;
- edge e;
-
- loop->num_pre_header_edges = 0;
- if (loop->num_entries != 1)
- return;
-
- ebb = loop->entry_edges[0]->src;
- if (ebb == ENTRY_BLOCK_PTR)
- return;
-
- /* Count number of edges along trace from loop header to
- root of pre-header extended basic block. Usually this is
- only one or two edges. */
- for (num = 1;
- EDGE_PRED (ebb, 0)->src != ENTRY_BLOCK_PTR && EDGE_COUNT (ebb->preds) == 1;
- num++)
- ebb = EDGE_PRED (ebb, 0)->src;
-
- loop->pre_header_edges = xmalloc (num * sizeof (edge));
- loop->num_pre_header_edges = num;
-
- /* Store edges in order that they are followed. The source of the first edge
- is the root node of the pre-header extended basic block and the
- destination of the last last edge is the loop header. */
- for (e = loop->entry_edges[0]; num; e = EDGE_PRED (e->src, 0))
- loop->pre_header_edges[--num] = e;
-}
-
-/* Return the block for the pre-header of the loop with header
- HEADER. Return NULL if there is no pre-header. */
-
-static basic_block
-flow_loop_pre_header_find (basic_block header)
-{
- basic_block pre_header;
- edge e;
- edge_iterator ei;
-
- /* If block p is a predecessor of the header and is the only block
- that the header does not dominate, then it is the pre-header. */
- pre_header = NULL;
- FOR_EACH_EDGE (e, ei, header->preds)
- {
- basic_block node = e->src;
-
- if (node != ENTRY_BLOCK_PTR
- && ! dominated_by_p (CDI_DOMINATORS, node, header))
- {
- if (pre_header == NULL)
- pre_header = node;
- else
- {
- /* There are multiple edges into the header from outside
- the loop so there is no pre-header block. */
- pre_header = NULL;
- break;
- }
- }
- }
-
- return pre_header;
-}
-