From 2c830108235685075e65fc1e2863d2e4125cb2ee Mon Sep 17 00:00:00 2001 From: Sebastian Hack Date: Sat, 30 Jun 2007 10:37:30 +0000 Subject: [PATCH] If a color colors all nodes in a chunk, other colors will not be tried anymore. Missing is a color sequence detection; at the moment, colors are used from 0..k-1. This is probably not so superb [r14864] --- ir/be/becopyheur4.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/ir/be/becopyheur4.c b/ir/be/becopyheur4.c index 8d202caa0..ee97153b6 100644 --- a/ir/be/becopyheur4.c +++ b/ir/be/becopyheur4.c @@ -1001,7 +1001,7 @@ static int change_node_color(co_mst_env_t *env, co_mst_irn_t *node, int tgt_col, return res; } - DEBUG_ONLY( +#ifndef NDEBUG if (firm_dbg_get_mask(dbg) & LEVEL_4) { if (node->fixed || node->tmp_fixed) DB((dbg, LEVEL_4, "\t\tCNC: %+F has already fixed color %d\n", node->irn, col)); @@ -1011,7 +1011,7 @@ static int change_node_color(co_mst_env_t *env, co_mst_irn_t *node, int tgt_col, DB((dbg, LEVEL_4, ")\n")); } } - ) +#endif return 0; } @@ -1023,6 +1023,7 @@ static int change_node_color(co_mst_env_t *env, co_mst_irn_t *node, int tgt_col, static void color_aff_chunk(co_mst_env_t *env, aff_chunk_t *c) { aff_chunk_t *best_chunk = NULL; int best_color = -1; + int did_all = 0; waitq *changed_ones = new_waitq(); waitq *tmp_chunks = new_waitq(); waitq *best_starts = NULL; @@ -1034,8 +1035,15 @@ static void color_aff_chunk(co_mst_env_t *env, aff_chunk_t *c) { DB((dbg, LEVEL_2, "\n")); - /* check which color is the "best" for the given chunk */ - for (col = 0; col < env->n_regs; ++col) { + /* 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 (col = 0; col < env->n_regs && !did_all; ++col) { int one_good = 0; waitq *good_starts = new_waitq(); aff_chunk_t *local_best; @@ -1046,6 +1054,9 @@ static void color_aff_chunk(co_mst_env_t *env, aff_chunk_t *c) { DB((dbg, LEVEL_3, "\ttrying color %d\n", col)); + /* suppose we can color all nodes to the same color */ + did_all = 1; + /* try to bring all nodes of given chunk to the current color. */ for (idx = 0, len = ARR_LEN(c->n); idx < len; ++idx) { ir_node *irn = c->n[idx]; @@ -1063,6 +1074,7 @@ static void color_aff_chunk(co_mst_env_t *env, aff_chunk_t *c) { if (good) waitq_put(good_starts, node); one_good |= good; + did_all &= good; DB((dbg, LEVEL_4, "\t\t... %+F attempt from %d to %d %s\n", irn, node->col, col, one_good ? "succeeded" : "failed")); } -- 2.20.1