+ir_exec_freq *
+compute_execfreq(ir_graph * irg, double loop_weight)
+{
+ gs_matrix_t *mat;
+ int size;
+ int idx;
+ freq_t *freq, *s, *e;
+ ir_exec_freq *ef;
+ set *freqs;
+ dfs_t *dfs;
+ double *x;
+ double norm;
+
+ /*
+ * compute a DFS.
+ * using a toposort on the CFG (without back edges) will propagate
+ * the values better for the gauss/seidel iteration.
+ * => they can "flow" from start to end.
+ */
+ dfs = dfs_new(&absgraph_irg_cfg_succ, irg);
+ ef = xmalloc(sizeof(ef[0]));
+ memset(ef, 0, sizeof(ef[0]));
+ ef->min_non_zero = HUGE_VAL; /* initialize with a reasonable large number. */
+ freqs = ef->set = new_set(cmp_freq, dfs_get_n_nodes(dfs));
+
+ /*
+ * Populate the exec freq set.
+ * The DFS cannot be used alone, since the CFG might not be connected
+ * due to unreachable code.
+ */
+ irg_block_walk_graph(irg, collect_blocks, NULL, freqs);
+
+ construct_cf_backedges(irg);
+ /* TODO: edges are corrupt for EDGE_KIND_BLOCK after the local optimize
+ graph phase merges blocks in the x86 backend */
+ edges_deactivate(irg);
+ edges_activate(irg);
+ /* edges_assure(irg); */
+
+ size = dfs_get_n_nodes(dfs);
+ mat = gs_new_matrix(size, size);
+ x = xmalloc(size*sizeof(*x));
+
+ for (idx = dfs_get_n_nodes(dfs) - 1; idx >= 0; --idx) {
+ ir_node *bb = (ir_node *) dfs_get_post_num_node(dfs, size - idx - 1);
+ freq_t *freq;
+ int i;