+static int is_modify_flags(ir_node *node) {
+ int i, arity;
+
+ if(arch_irn_is(arch_env, node, modify_flags))
+ return 1;
+ if(!be_is_Keep(node))
+ return 0;
+
+ arity = get_irn_arity(node);
+ for(i = 0; i < arity; ++i) {
+ ir_node *in = get_irn_n(node, i);
+ in = skip_Proj(in);
+ if(arch_irn_is(arch_env, in, modify_flags))
+ return 1;
+ }
+
+ return 0;
+}
+
+/**
+ * walks up the schedule and makes sure there are no flag-destroying nodes
+ * between a flag-consumer -> flag-producer chain. Fixes problematic situations
+ * by moving and/or rematerialisation of the flag-producers.
+ * (This can be extended in the future to do some register allocation on targets
+ * like ppc32 where we conceptually have 8 flag registers)
+ */