+ ++env->chunk_visited;
+
+ /* compute color preference */
+ for (pos = 0, len = ARR_LEN(c->interfere); pos < len; ++pos) {
+ const ir_node *n = c->interfere[pos];
+ co_mst_irn_t *node = get_co_mst_irn(env, n);
+ aff_chunk_t *chunk = node->chunk;
+
+ if (is_loose(node) && chunk && chunk->visited < env->chunk_visited) {
+ assert(!chunk->deleted);
+ chunk->visited = env->chunk_visited;
+ ++n_int_chunks;
+
+ aff_chunk_assure_weight(env, chunk);
+ for (i = 0; i < env->n_regs; ++i)
+ order[i].cost += chunk->color_affinity[i].cost;
+ }
+ }
+
+ for (i = 0; i < env->n_regs; ++i) {
+ real_t dislike = n_int_chunks > 0 ? REAL(1.0) - order[i].cost / n_int_chunks : REAL(0.0);
+ order[i].col = i;
+ order[i].cost = (REAL(1.0) - dislike_influence) * c->color_affinity[i].cost + dislike_influence * dislike;
+ }
+
+ qsort(order, env->n_regs, sizeof(order[0]), cmp_col_cost_gt);
+
+ DBG_COL_COST(env, LEVEL_2, order);
+ DB((dbg, LEVEL_2, "\n"));
+
+ /* check which color is the "best" for the given chunk.
+ * if we found a color which was ok for all nodes, we take it
+ * and do not look further. (see did_all flag usage below.)
+ * If we have many colors which fit all nodes it is hard to decide
+ * which one to take anyway.
+ * TODO Sebastian: Perhaps we should at all nodes and figure out
+ * a suitable color using costs as done above (determine_color_costs).
+ */
+ for (i = 0; i < env->k; ++i) {
+ int col = order[i].col;
+ waitq *good_starts = new_waitq();