pan/midgard: Add distance metric to choose_instruction
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Sat, 28 Sep 2019 00:18:16 +0000 (20:18 -0400)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Mon, 30 Sep 2019 12:40:13 +0000 (08:40 -0400)
We require chosen instructions to be "close", to avoid ballooning
register pressure. This is a kludge that will go away once we have
proper liveness tracking in the scheduler, but for now it prevents a lot
of needless spilling.

v2: Lower threshold to 6 (from 8). Schedule is hurt, but a few shaders
that spilled excessively are fixed.

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

src/panfrost/midgard/midgard_schedule.c

index dea8b023e9d1ee2fcbe24a9b71da2bd63c630127..8aaec6f8e438f9c16de36ed71b7c4b878b116b53 100644 (file)
@@ -898,7 +898,21 @@ mir_choose_instruction(
 
         signed best_index = -1;
 
+        /* Enforce a simple metric limiting distance to keep down register
+         * pressure. TOOD: replace with liveness tracking for much better
+         * results */
+
+        unsigned max_active = 0;
+        unsigned max_distance = 6;
+
         BITSET_FOREACH_SET(i, tmp, worklist, count) {
+                max_active = MAX2(max_active, i);
+        }
+
+        BITSET_FOREACH_SET(i, tmp, worklist, count) {
+                if ((max_active - i) >= max_distance)
+                        continue;
+
                 if (tag != ~0 && instructions[i]->type != tag)
                         continue;