+int sched_skip_phi_predicator(const ir_node *irn, void *data) {
+ return is_Phi(irn);
+}
+
+/* Skip nodes in a schedule. */
+ir_node *sched_skip(ir_node *from, int forward, sched_predicator_t *predicator, void *data)
+{
+ const ir_node *bl = get_block(from);
+ ir_node *curr;
+
+ if (is_Block(from))
+ from = forward ? sched_next(from) : sched_prev(from);
+
+ for(curr = from; curr != bl && predicator(curr, data); curr = forward ? sched_next(curr) : sched_prev(curr));
+
+ return curr;
+}
+
+/** A simple forward single linked list. */
+typedef struct {
+ ir_node *start; /**< start of the list */
+ ir_node *end; /**< last block in the list */
+ unsigned n_blks; /**< number of blocks in the list */
+} anchor;
+
+static void add_block(anchor *list, ir_node *block) {
+ if(list->start == NULL) {
+ list->start = block;
+ list->end = block;
+ } else {
+ set_irn_link(list->end, block);
+ list->end = block;
+ }
+
+ list->n_blks++;
+}
+
+static void create_block_list(ir_node *leader_block, anchor *list) {
+ int i;
+ ir_node *block = NULL;
+ const ir_edge_t *edge;
+
+ ir_extblk *extbb = get_Block_extbb(leader_block);
+ if(extbb_visited(extbb))
+ return;
+ mark_extbb_visited(extbb);
+
+ for(i = 0; i < get_extbb_n_blocks(extbb); ++i) {
+ block = get_extbb_block(extbb, i);
+ add_block(list, block);
+ }
+
+ assert(block != NULL);
+
+ // pick successor extbbs
+ foreach_block_succ(block, edge) {
+ ir_node *succ = get_edge_src_irn(edge);
+
+ create_block_list(succ, list);
+ }
+
+ for(i = 0; i < get_extbb_n_blocks(extbb) - 1; ++i) {
+ block = get_extbb_block(extbb, i);
+ foreach_block_succ(block, edge) {
+ ir_node *succ = get_edge_src_irn(edge);
+
+ create_block_list(succ, list);
+ }
+ }
+}
+
+void compute_extbb_execfreqs(ir_graph *irg, exec_freq_t *execfreqs);
+
+/*
+ * Calculates a block schedule. The schedule is stored as a linked
+ * list starting at the start_block of the irg.
+ */
+ir_node **sched_create_block_schedule(ir_graph *irg, exec_freq_t *execfreqs)
+{
+ anchor list;
+ ir_node **blk_list, *b, *n;
+ unsigned i;
+
+ /* schedule extended basic blocks */
+ compute_extbb_execfreqs(irg, execfreqs);
+ //compute_extbb(irg);
+
+ list.start = NULL;
+ list.end = NULL;
+ list.n_blks = 0;
+ inc_irg_block_visited(irg);
+ create_block_list(get_irg_start_block(irg), &list);
+
+ /** create an array, so we can go forward and backward */
+ blk_list = NEW_ARR_D(ir_node *, irg->obst,list.n_blks);
+
+ for (i = 0, b = list.start; b; b = n, ++i) {
+ n = get_irn_link(b);
+ blk_list[i] = b;
+ }
+
+ return blk_list;
+}
+
+typedef struct remove_dead_nodes_env_t_ {
+ ir_graph *irg;
+ bitset_t *reachable;
+} remove_dead_nodes_env_t;
+
+static void mark_dead_nodes_walker(ir_node *node, void *data)