-static void construct_interval_block(ir_node *b, ir_loop *l) {
- int i, n_cfgpreds = get_Block_n_cfgpreds(b);
-
- if (b == get_irg_start_block(current_ir_graph)) return;
- /* We want nice blocks. */
- assert(n_cfgpreds > 0);
-
- for (i = 0; i < n_cfgpreds; ++i) {
- ir_node *cfop, *pred;
- ir_loop *pred_l;
-
- if (is_backedge(b, i)) {
- if (b != get_loop_element(l, 0).node) {
- if (get_firm_verbosity()) {
- printf("Loophead not at loop position 0. "); DDMN(b);
- }
- }
- /* There are no backedges in the interval decomposition. */
- add_region_in(b, NULL);
- continue;
- }
-
- cfop = skip_Proj(get_Block_cfgpred(b, i));
- pred = get_nodes_block(cfop);
- /* We want nice blocks. */
- assert( get_irn_op(pred) != op_Bad
- && get_irn_op(skip_Proj(get_Block_cfgpred(b, i))) != op_Bad);
- pred_l = get_irn_loop(pred);
- if (pred_l == l) {
- add_region_in(b, pred);
- //if (is_fragile_op(cfop)) inc_region_n_exc_outs(b);
- exc_outs(pred, cfop);
- } else {
- int found = find_inner_loop(b, l, pred, cfop);
- if (!found) {
- if (b != get_loop_element(l, 0).node) {
- if (get_firm_verbosity()) {
- printf("Loop entry not at loop position 0. "); DDMN(b);
- }
- }
- found = find_outer_loop(l, pred_l, pred, cfop);
- if (found) add_region_in(b, NULL); /* placeholder */
- }
- if (!found) {
- found = find_previous_loop(l, pred_l, b, pred, cfop);
- }
- if (!found) {
- DDMG(current_ir_graph);
- DDMN(b);
- DDMN(pred);
- assert(is_backedge(b, i));
- assert(found && "backedge from inner loop");
- }
- }
-
- if (b != get_loop_element(l, 0).node) {
- /* Check for improper region */
- if (has_backedges(b)) {
- printf("Improper Region!!!!!!\n");
- DDMG(current_ir_graph);
- DDMN(b);
- DDML(l);
- }
- }
- }
+static void construct_interval_block(ir_node *blk, ir_loop *l)
+{
+ int i, n_cfgpreds;
+
+ if (blk == get_irg_start_block(current_ir_graph))
+ return;
+
+ n_cfgpreds = get_Block_n_cfgpreds(blk);
+ /* We want nice blocks. */
+ assert(n_cfgpreds > 0);
+
+ for (i = 0; i < n_cfgpreds; ++i) {
+ ir_node *cfop, *pred;
+ ir_loop *pred_l;
+
+ if (is_backedge(blk, i)) {
+ if (blk != get_loop_element(l, 0).node) {
+ DB((dbg, LEVEL_1, "Loophead not at loop position 0. %+F\n", blk));
+ }
+ /* There are no backedges in the interval decomposition. */
+ add_region_in(blk, NULL);
+ continue;
+ }
+
+ cfop = get_Block_cfgpred(blk, i);
+ if (is_Proj(cfop)) {
+ ir_node *op = skip_Proj(cfop);
+ if (is_x_except_Proj(cfop)) {
+ /*
+ * Skip the Proj for the exception flow only, leave the
+ * not exception flow Proj's intact.
+ * If the old semantic is used (only one exception Proj) this
+ * should lead to the same representation as before.
+ */
+ cfop = op;
+ } else {
+ assert(get_nodes_block(cfop) == get_nodes_block(skip_Proj(cfop)));
+ }
+ }
+
+ pred = skip_Proj(get_nodes_block(cfop));
+ /* We want nice blocks. */
+ assert(!is_Bad(pred) && !is_Bad(skip_Proj(get_Block_cfgpred(blk, i))));
+ pred_l = get_irn_loop(pred);
+ if (pred_l == l) {
+ /* first case: both blocks are in the same loop */
+ add_region_in(blk, pred);
+ exc_outs(pred, cfop);
+ } else {
+ /* check for the second case: pred is from an inner loop */
+ int found = find_inner_loop(blk, l, pred, cfop);
+ if (!found) {
+ if (blk != get_loop_element(l, 0).node) {
+ DB((dbg, LEVEL_1, "Loop entry not at loop position 0. %+F\n", blk));
+ }
+ /* check for the third case: pred is in an outer loop */
+ found = find_outer_loop(l, pred_l, pred, cfop);
+ if (found) {
+ /* placeholder: the edge is added to the loop region */
+ add_region_in(blk, NULL);
+ } else {
+ /* fourth case: pred is from the previous loop */
+ found = find_previous_loop(l, pred_l, blk, pred, cfop);
+
+ assert(found && "decomposition failed");
+ }
+ }
+ }
+
+#ifdef DEBUG_libfirm
+ if (blk != get_loop_element(l, 0).node) {
+ /* Check for improper region. But these can happen, so what? */
+ if (has_backedges(blk)) {
+ DB((dbg, LEVEL_1, "Improper Region %+F\n", blk));
+ }
+ }
+#endif
+ }