[Mesa-dev] [PATCH] register_allocate: don't consider trivially colorable registers for spilling.
Paul Berry
stereotype441 at gmail.com
Mon Oct 1 15:43:39 PDT 2012
Previously, we considered all registers as candidates for spilling.
This was counterproductive--for any registers that have already been
removed from the interference graph, there is no benefit to spilling
them, since they don't contribute to register pressure.
This patch ensures that we will only try to spill registers that are
still in the interference graph after register allocation has failed.
This is consistent with the recommendations of the paper "Retargetable
Graph-Coloring Register Allocation for Irregular Architectures", on
which our register allocator is based.
---
Note: I haven't found a shader whose performance is significantly
improved by this patch (it seems that usually, our heuristics happen
to select registers that are still in the interference graph), but it
still seems justified on theoretical grounds.
src/mesa/program/register_allocate.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/src/mesa/program/register_allocate.c b/src/mesa/program/register_allocate.c
index 97d4e33..88793db 100644
--- a/src/mesa/program/register_allocate.c
+++ b/src/mesa/program/register_allocate.c
@@ -555,6 +555,13 @@ ra_get_best_spill_node(struct ra_graph *g)
if (cost <= 0.0)
continue;
+ /* Only consider registers for spilling if they are still in the
+ * interference graph (those on the stack have already been proven to be
+ * allocatable without spilling).
+ */
+ if (g->nodes[n].in_stack)
+ continue;
+
benefit = ra_get_spill_benefit(g, n);
if (benefit / cost > best_benefit) {
--
1.7.12.1
More information about the mesa-dev
mailing list