fixed optimize_conv_conv(): when the result is 8bit, we must change the opcode AND...
[libfirm] / ir / be / becopyheur4.c
index f93bfcc..ee97153 100644 (file)
@@ -130,7 +130,7 @@ typedef int decide_func_t(const co_mst_irn_t *node, int col);
  * Write a chunk to stderr for debugging.
  */
 static void dbg_aff_chunk(const co_mst_env_t *env, const aff_chunk_t *c) {
-       int idx;
+       bitset_pos_t idx;
        if (c->weight_consistent)
                ir_fprintf(stderr, " $%d ", c->weight);
        ir_fprintf(stderr, "{");
@@ -145,7 +145,9 @@ static void dbg_aff_chunk(const co_mst_env_t *env, const aff_chunk_t *c) {
  * Dump all admissible colors to stderr.
  */
 static void dbg_admissible_colors(const co_mst_env_t *env, const co_mst_irn_t *node) {
-       int idx;
+       bitset_pos_t idx;
+       (void) env;
+
        if (bitset_popcnt(node->adm_colors) < 1)
                fprintf(stderr, "no admissible colors?!?");
        else {
@@ -191,6 +193,8 @@ static int decider_hasnot_color(const co_mst_irn_t *node, int col) {
  * Always returns true.
  */
 static int decider_always_yes(const co_mst_irn_t *node, int col) {
+       (void) node;
+       (void) col;
        return 1;
 }
 
@@ -324,6 +328,7 @@ static void *co_mst_irn_init(ir_phase *ph, ir_node *irn, void *old) {
  * Check if affinity chunk @p chunk interferes with node @p irn.
  */
 static INLINE int aff_chunk_interferes(co_mst_env_t *env, const aff_chunk_t *chunk, ir_node *irn) {
+       (void) env;
        return bitset_is_set(chunk->interfere, get_irn_idx(irn));
 }
 
@@ -764,7 +769,8 @@ static INLINE void reject_coloring(waitq *nodes) {
 static void determine_color_costs(co_mst_env_t *env, co_mst_irn_t *node, col_cost_t *costs) {
        affinity_node_t *an = get_affinity_info(env->co, node->irn);
        neighb_t        *aff_neigh;
-       int             idx, i;
+       bitset_pos_t     idx;
+       int              i;
 
        col_cost_init(env, costs, 0.0);
 
@@ -995,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));
@@ -1005,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;
 }
@@ -1017,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;
@@ -1028,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;
@@ -1040,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];
@@ -1057,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"));
                }