- worklist_entry_t *wl_entry
- = list_entry(entry, worklist_entry_t, head);
- ir_node *value = wl_entry->value;
-
- if(irn_visited(value))
- continue;
-
- place_reload(wl_entry);
+ worklist_entry_t *wl_entry = list_entry(entry, worklist_entry_t, head);
+ ir_node *value = wl_entry->value;
+
+ if(!irn_visited(value)) {
+ /* if we still have room in the worklist, then we can simply take
+ * the value */
+ if(current_worklist->n_live_values < n_regs) {
+ worklist_entry_t *new_entry
+ = obstack_alloc(&obst, sizeof(new_entry[0]));
+
+ new_entry->value = value;
+ new_entry->reload_point = wl_entry->reload_point;
+ new_entry->next_reload = wl_entry->next_reload;
+ set_irn_link(value, new_entry);
+ mark_irn_visited(value);
+ list_add(&new_entry->head, ¤t_worklist->live_values);
+ ++current_worklist->n_live_values;
+ } else {
+ /* value is not in current worklist, place reloads */
+ place_reload(wl_entry);
+ }
+ } else {
+ /* value is in current worklist, link it with the reload point
+ * from this path */
+ worklist_entry_t *active_entry = get_irn_link(value);
+ wl_entry->next_reload = active_entry->next_reload;
+ active_entry->next_reload = wl_entry;
+ }