diff options
author | Maximilian Stemmer-Grabow <mail@mxsg.de> | 2021-07-12 17:38:14 +0200 |
---|---|---|
committer | Andreas Fried <andreas.fried@kit.edu> | 2021-12-02 12:57:28 +0100 |
commit | 67aa1788a692818f7b8627940765a8fe36346a76 (patch) | |
tree | b60123a42879e689858bc5f1ebd2d9ff7e14cff7 | |
parent | 81ddcd60812dc146fd3d3f57b2cd2b1845a70c43 (diff) |
Rebased: Prune linked requirements when others are fixed
-rw-r--r-- | ir/be/becopyheur4.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/ir/be/becopyheur4.c b/ir/be/becopyheur4.c index 96ba3ec..a76b41f 100644 --- a/ir/be/becopyheur4.c +++ b/ir/be/becopyheur4.c @@ -137,6 +137,8 @@ typedef struct co_mst_irn_t { /** The number of uses of this node that have a register restriction to be compressed. */ int comp_use_count; + + bool uncompressable : 1; /**< Mark this node as not compressible (for debug purposes). */ } co_mst_irn_t; static double scaled_edge_weight(const aff_edge_t * edge) @@ -158,6 +160,7 @@ static int compressable_uses_count(co_mst_env_t *env, const ir_node *irn) { // To do this, we use the nodes' out edges, so verify they are correct // Note: This is only required once, not for every node, but keep it here for now + // Todo Move this to initialization as the irg structure is not changed here assure_irg_properties(irn->irg, IR_GRAPH_PROPERTY_CONSISTENT_OUT_EDGES); int comp_uses_count = 0; @@ -1232,6 +1235,9 @@ static void color_aff_chunk(co_mst_env_t *env, aff_chunk_t *c) for (unsigned i = 0, n = env->n_regs; i < n; ++i) { /* skip ignore colors */ unsigned col = order[i].col; + + bool col_compressible = env->get_compression_reqs && bitset_is_set(env->compressible_regs, i); + if (!bitset_is_set(env->allocatable_regs, col)) continue; @@ -1242,6 +1248,7 @@ static void color_aff_chunk(co_mst_env_t *env, aff_chunk_t *c) for (size_t idx = 0, len = ARR_LEN(c->n); idx < len; ++idx) { const ir_node *irn = c->n[idx]; co_mst_irn_t *node = get_co_mst_irn(env, irn); + affinity_node_t *aff_node = get_affinity_info(env->co, irn); assert(!node->fixed && "Node must not have a fixed color."); DB((dbg, LEVEL_4, "\t\tBringing %+F from color %d to color %d ...\n", irn, node->col, col)); @@ -1256,6 +1263,37 @@ static void color_aff_chunk(co_mst_env_t *env, aff_chunk_t *c) if (good) { materialize_coloring(&changed); node->fixed = 1; + + // Prune compression requirements if applicable + if (env->get_compression_reqs) { + compression_req_t req = env->get_compression_reqs(node->irn); + + // We are handling compression requirements + // Todo Can this be factored such that we do not need to check this explicitly? + + // Remove restrictions for compressible registers + if (!col_compressible + && (req == comp_req_register_subset || req == comp_req_2addr_register_subset) + && !node->uncompressable) { + + node->uncompressable = true; + + c->comp_reg_use_count -= node->comp_use_count; + c->comp_reg_restr_count -= node->comp_reg_restricted; + } + + // Disable 2-address requirement edge if the register requirement cannot + // be fulfilled anymore; this is only applicable if the current color is not from the + // compressible color subset + if (!col_compressible + && req == comp_req_2addr_register_subset) { + co_gs_foreach_neighb(aff_node, neighb) { + if (neighb->aff_type == aff_edge_compression) { + neighb->pruned = true; + } + } + } + } } else { reject_coloring(&changed); } @@ -1268,6 +1306,16 @@ static void color_aff_chunk(co_mst_env_t *env, aff_chunk_t *c) for (size_t idx = 0, len = ARR_LEN(c->n); idx < len; ++idx) { co_mst_irn_t *node = get_co_mst_irn(env, c->n[idx]); node->fixed = 0; + + // Replace pruned requirements + if (env->get_compression_reqs) { + if (node->uncompressable) { + node->uncompressable = false; + + c->comp_reg_use_count += node->comp_use_count; + c->comp_reg_restr_count += node->comp_reg_restricted; + } + } } /* try next color when failed */ |