- if (operand == def) {
- DBG((uses->dbg, LEVEL_3, "found use of %+F at %+F\n", operand, node));
- return step;
- }
+ arg = get_irn_n(node, i);
+ if (arg == def)
+ return 1;
+ }
+
+ return 0;
+}
+
+static inline unsigned get_step(const ir_node *node)
+{
+ return PTR_TO_INT(get_irn_link(node));
+}
+
+static be_next_use_t get_next_use(be_uses_t *env, ir_node *from,
+ unsigned from_step, const ir_node *def,
+ int skip_from_uses)
+{
+ unsigned step = from_step;
+ ir_node *block = get_nodes_block(from);
+ ir_node *next_use;
+ ir_node *node;
+ unsigned timestep;
+ unsigned next_use_step;
+ const ir_edge_t *edge;
+
+ assert(skip_from_uses == 0 || skip_from_uses == 1);
+ if (skip_from_uses) {
+ from = sched_next(from);
+ }
+
+ next_use = NULL;
+ next_use_step = INT_MAX;
+ timestep = get_step(from);
+ foreach_out_edge(def, edge) {
+ ir_node *node = get_edge_src_irn(edge);
+ unsigned node_step;
+
+ if (is_Anchor(node))
+ continue;
+ if (get_nodes_block(node) != block)
+ continue;
+ if (is_Phi(node))
+ continue;
+
+ node_step = get_step(node);
+ if (node_step < timestep)
+ continue;
+ if (node_step < next_use_step) {
+ next_use = node;
+ next_use_step = node_step;