Mesa (master): pan/midgard: Compute spill costs

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Nov 14 02:58:51 UTC 2019


Module: Mesa
Branch: master
Commit: 23c83f3f05d95c9ee519914a5798fd72d880d8bc
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=23c83f3f05d95c9ee519914a5798fd72d880d8bc

Author: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Date:   Sat Oct 26 10:08:18 2019 -0400

pan/midgard: Compute spill costs

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>

---

 src/panfrost/midgard/midgard_schedule.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/panfrost/midgard/midgard_schedule.c b/src/panfrost/midgard/midgard_schedule.c
index e5ec8f87225..588f7c6302e 100644
--- a/src/panfrost/midgard/midgard_schedule.c
+++ b/src/panfrost/midgard/midgard_schedule.c
@@ -1195,10 +1195,21 @@ static void mir_spill_register(
          * spill node. All nodes are equal in spill cost, but we can't spill
          * nodes written to from an unspill */
 
-        for (unsigned i = 0; i < ctx->temp_count; ++i) {
-                lcra_set_node_spill_cost(l, i, 1);
+        unsigned *cost = calloc(ctx->temp_count, sizeof(cost[0]));
+
+        mir_foreach_instr_global(ctx, ins) {
+                if (ins->dest < ctx->temp_count)
+                        cost[ins->dest]++;
+
+                mir_foreach_src(ins, s) {
+                        if (ins->src[s] < ctx->temp_count)
+                                cost[ins->src[s]]++;
+                }
         }
 
+        for (unsigned i = 0; i < ctx->temp_count; ++i)
+                lcra_set_node_spill_cost(l, i, cost[i]);
+
         /* We can't spill any bundles that contain unspills. This could be
          * optimized to allow use of r27 to spill twice per bundle, but if
          * you're at the point of optimizing spilling, it's too late.




More information about the mesa-commit mailing list