summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMaximilian Stemmer-Grabow <mail@mxsg.de>2021-06-11 15:12:03 +0200
committerAndreas Fried <andreas.fried@kit.edu>2021-12-02 12:57:28 +0100
commit723c902f8f40ce7e8b23b811c57c3738b862e439 (patch)
tree8cf9ec5de42cff23d344e94c993fc68e61f217bc
parent6a06aa779348c701b0b344c6113b38c97bbcb2b3 (diff)
Calculate the number of uses with compressibility register requirements
-rw-r--r--ir/be/becopyheur4.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/ir/be/becopyheur4.c b/ir/be/becopyheur4.c
index 31f2d48..7ba3a70 100644
--- a/ir/be/becopyheur4.c
+++ b/ir/be/becopyheur4.c
@@ -78,6 +78,9 @@ typedef struct aff_chunk_t {
/** The number of nodes in this chunk that have a register requirement to allow to be compressed */
int comp_reg_restr_count;
+ /** The number of nodes with a compression register requirement that use values in this chunk */
+ int comp_reg_use_count;
+
#ifndef NDEBUG
bool deleted : 1; /**< For debugging: Set if the chunk was deleted. */
#endif
@@ -131,6 +134,9 @@ typedef struct co_mst_irn_t {
/** The node has a register restriction to be compressed. */
bool comp_reg_restricted : 1;
+
+ /** The number of uses of this node that have a register restriction to be compressed. */
+ int comp_use_count;
} co_mst_irn_t;
static double scaled_edge_weight(const aff_edge_t * edge)
@@ -186,8 +192,13 @@ static co_mst_irn_t *co_mst_irn_init(co_mst_env_t *env, const ir_node *irn)
compression_reqs_fct_t get_compression_reqs = env->get_compression_reqs;
if(get_compression_reqs) {
+ /* Check for direct register compressibility requirements on the node itself */
compression_req_t req = get_compression_reqs(irn);
res->comp_reg_restricted = (req == comp_req_register_subset) || (req == comp_req_2addr_register_subset);
+
+ /* Count the number of uses that require a compressible register to be compressed */
+ res->comp_use_count = compressable_uses_count(env, irn);
+ // DB((dbg, LEVEL_4, "Found %d compressible uses for node %+F\n", res->comp_use_count, irn));
}
/* set admissible registers */
@@ -566,17 +577,22 @@ static void aff_chunk_assure_weight(co_mst_env_t *env, aff_chunk_t *c)
}
int register_restr_count = 0;
+ int register_restr_uses = 0;
+
double w = 0.0;
for (unsigned idx = 0, len = ARR_LEN(c->n); idx < len; ++idx) {
const ir_node *n = c->n[idx];
const affinity_node_t *an = get_affinity_info(env->co, n);
co_mst_irn_t *node = get_co_mst_irn(env, n);
- // Check for register restrictions on the node
+ // Check for register restrictions on the node itself
if(node->comp_reg_restricted) {
register_restr_count++;
}
+ // Count the number of uses that may be compressed when this node's value ends up
+ // in a compressible register
+ register_restr_uses += node->comp_use_count;
node->chunk = c;
if (node->constr_factor > 0.0) {
@@ -607,7 +623,13 @@ static void aff_chunk_assure_weight(co_mst_env_t *env, aff_chunk_t *c)
DB((dbg, LEVEL_4, "Recalculate weight for chunk #%u (adjusted col: from -> to): ", c->id));
- double compressibility_factor = c->comp_reg_restr_count / (double)ARR_LEN(c->n);
+ // The compressibility is calculated from the number of nodes whose compressibility is directly affected
+ // by the chosen register themselves as well as the number of other nodes that rely on the value from
+ // the node itself to be in a compressible register to be compressed themselves.
+
+ double compressibility_factor = register_restr_count / (double)ARR_LEN(c->n);
+
+ // DB((dbg, LEVEL_1, "Compressibility factor: %f, length: %d\n", compressibility_factor, ARR_LEN(c->n)));
for (unsigned i = 0, n = env->n_regs; i < n; ++i) {
double prior_cost = c->color_affinity[i].cost * (1.0 / ARR_LEN(c->n));
@@ -626,6 +648,7 @@ static void aff_chunk_assure_weight(co_mst_env_t *env, aff_chunk_t *c)
DB((dbg, LEVEL_4, "\n"));
c->comp_reg_restr_count = register_restr_count;
+ c->comp_reg_use_count = register_restr_uses;
c->weight = w;
c->weight_consistent = true;