+#ifndef NDEBUG
+/**
+ * Returns non-zero if node has no backarray, or
+ * if size of backarray == size of in array.
+ */
+static int legal_backarray(ir_node *n) {
+ unsigned *ba = mere_get_backarray(n);
+ if (ba && (rbitset_size(ba) != (unsigned) get_irn_arity(n)))
+ return 0;
+ return 1;
+}
+#endif
+
+void fix_backedges(struct obstack *obst, ir_node *n) {
+ unsigned *arr = mere_get_backarray(n);
+ ir_opcode opc;
+ int arity;
+
+ if (! arr)
+ return;
+
+ arity = get_irn_arity(n);
+ if (rbitset_size(arr) != (unsigned) arity) {
+ arr = new_backedge_arr(obst, arity);
+
+ opc = get_irn_opcode(n);
+ if (opc == iro_Phi)
+ n->attr.phi.u.backedge = arr;
+ else if (opc == iro_Block) {
+ if (!get_interprocedural_view())
+ n->attr.block.backedge = arr;
+ else
+ n->attr.block.cg_backedge = arr;
+ }
+ else if (opc == iro_Filter)
+ n->attr.filter.backedge = arr;
+ }
+
+ assert(legal_backarray(n));
+}
+
+#ifdef INTERPROCEDURAL_VIEW
+int is_inter_backedge(ir_node *n, int pos) {
+ int res;
+ int rem = get_interprocedural_view();
+ set_interprocedural_view(0);
+ res = is_backedge(n, pos);
+ set_interprocedural_view(rem);
+ return res;
+}
+
+int is_intra_backedge(ir_node *n, int pos) {
+ int res;
+ int rem = get_interprocedural_view();
+ set_interprocedural_view(1);
+ res = is_backedge(n, pos);
+ set_interprocedural_view(rem);
+ return res;
+}
+#endif
+
+
+/* Returns non-zero if the predecessor pos is a backedge. */
+int is_backedge(ir_node *n, int pos) {
+ unsigned *ba = get_backarray(n);
+ if (ba)
+ return rbitset_is_set(ba, pos);
+ return 0;