- unsigned next_use = USES_INFINITY;
- unsigned step = from_step;
- unsigned n = 0;
- const ir_node *irn;
- const ir_node *bl = get_block(from);
- const ir_edge_t *succ_edge;
-
- sched_foreach_from(from, irn) {
- int i, n;
-
- for(i = 0, n = get_irn_arity(irn); i < n; ++i) {
- ir_node *operand = get_irn_n(irn, i);
-
- if(operand == def) {
- DBG((uses->dbg, LEVEL_3, "found use of %+F at %+F\n", operand, irn));
- return step;
- }
- }
-
- step++;
- }
-
- next_use = step;
- foreach_block_succ(bl, succ_edge) {
- const ir_node *succ_bl = succ_edge->src;
- if(is_live_in(succ_bl, def)) {
- unsigned next = get_next_use_bl(uses, succ_bl, def);
-
- DBG((uses->dbg, LEVEL_2, "\t\tnext use in succ %+F: %d\n", succ_bl, next));
- next_use = sadd(next_use, next);
- n++;
- }
- }
+ unsigned next_use = USES_INFINITY;
+ unsigned step = from_step;
+ unsigned n = 0;
+ ir_node *bl = get_nodes_block(from);
+ const ir_node *irn;
+ const ir_edge_t *succ_edge;
+
+ set_irn_visited(bl, visited_nr);
+
+ sched_foreach_from(from, irn) {
+ int i, n;
+
+ if(!skip_from_uses) {
+ for(i = 0, n = get_irn_arity(irn); i < n; ++i) {
+ ir_node *operand = get_irn_n(irn, i);
+
+ if(operand == def) {
+ DBG((uses->dbg, LEVEL_3, "found use of %+F at %+F\n", operand, irn));
+ return step;
+ }
+ }
+ }
+
+ skip_from_uses = 0;
+ step++;
+ }
+
+ next_use = USES_INFINITY;
+ foreach_block_succ(bl, succ_edge) {
+ const ir_node *succ_bl = succ_edge->src;
+ if(get_irn_visited(succ_bl) < visited_nr && (is_live_in(succ_bl, def) || (get_irn_arity(succ_bl) > 1 && is_live_end(bl, def)))) {
+ unsigned next = get_next_use_bl(uses, succ_bl, def);
+
+ DBG((uses->dbg, LEVEL_2, "\t\tnext use in succ %+F: %d\n", succ_bl, next));
+ next_use = MIN(next_use, next);
+ n++;
+ }
+ }
+
+ return next_use + step;
+}