summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMaximilian Stemmer-Grabow <mail@mxsg.de>2021-07-22 17:54:50 +0200
committerAndreas Fried <andreas.fried@kit.edu>2021-12-02 12:57:28 +0100
commit11d27a178094c094d04cbd4675cb2eb8596f3be1 (patch)
treef53fcef15064c973b3e0565b5f85665e4955804e
parent1640c71bbee9c11ea7d531ad408035ecae911e8c (diff)
Add cost comparison function that sorts by color compressibility
This is useful for checking stability of the method under permutation of the compressible register indices.
-rw-r--r--ir/be/becopyheur4.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/ir/be/becopyheur4.c b/ir/be/becopyheur4.c
index e19ad58..745b39d 100644
--- a/ir/be/becopyheur4.c
+++ b/ir/be/becopyheur4.c
@@ -363,6 +363,28 @@ static int cmp_col_cost_lt(const void *a, const void *b)
return cmp_col_cost_gt(b, a);
}
+// TODO(temporary): To check for stability under register permutation,
+// sort by the fact whether the registers are compressible
+static int cmp_col_cost_gt_compressibility(const void *a, const void *b, co_mst_env_t *env)
+{
+ const col_cost_t *c1 = (const col_cost_t*)a;
+ const col_cost_t *c2 = (const col_cost_t*)b;
+ double diff = c2->cost - c1->cost;
+
+ if (diff > 0)
+ return 1;
+ if (diff < 0)
+ return -1;
+
+ bool c1_compr = bitset_is_set(env->compressible_regs, c1->col);
+ bool c2_compr = bitset_is_set(env->compressible_regs, c2->col);
+
+ if (c1_compr != c2_compr)
+ return c1_compr ? -1 : 1;
+
+ return QSORT_CMP(c1->col, c2->col);
+}
+
/**
* Creates a new affinity chunk
*/